I trying to learn java generic, from here I got below method definition, in this can someone explain why we are declaring <T extends Comparable<T>> before the return type.
public static <T extends Comparable<T>> int countGreaterThan(T[] anArray, T elem)
I know the usage of Comparable interface, but why we need this <T extends Comparable<T>> before the return type of the method?
Rather we can write like public static int countGreaterThan(T[] anArray, T elem), which will also take generic parameters
So my question is Why we need <T extends Comparable<T>> or just a <T> there?
