Вот мой код:
Основной метод
Код: Выделить всё
public static void main(String[] args) {
Integer intArray[] = { 13, 25, 46, 65, 12, 23};
Double doubleArray[] = {1.2, 3.4, 1.1, 0.1, 5.6};
String stringArray[] = {"H", "E", "L", "L", "O"};
System.out.println("The smallest number is: " + myMin(doubleArray));
System.out.println("The median is: " + median(doubleArray));
System.out.println("The median is: " + median(stringArray));
System.out.println("The max is: " + max2(intArray));
}
Код: Выделить всё
public static E max2(E... elements) {
Arrays.sort(elements);
E max = elements[0];
for (E element : elements) {
if (element.compareTo(max) > 0) {
max = element;
}
}
return max;
}