Yes, there is a workaround by adding a Comparable upper bound to T
Since the < operator does not work with objects, you should use the equivalent functionality, which is the compareTo method in the Comparable interface.
Verify that type T is Comparable by specifying an upper bound.
private static <T extends Comparable<T>> T getMax(T[] array)
Then, instead of the > operator > call compareTo :
if(array[i].compareTo(max) > 0)
source share