I want to write a method to find the max value of arraylist. It could be integer or double type.
I believe the below code works for arrays, but not for arraylist?
public static <T extends Comparable<T>> T maxValue(T[] array){
T max = array[0];
for(T data: array){
if(data.compareTo(max)>0)
max =data;
}
return max;
}
get)?ArrayListand explain where exactly you're stuck?