I was wondering what static <T>
means in this context? or is it <T> void
?
I know what static and void both mean but I'm not sure what <T>
means here
static <T> void sort(List<T> list, Comparator<? super T> c)
I was wondering what static <T>
means in this context? or is it <T> void
?
I know what static and void both mean but I'm not sure what <T>
means here
static <T> void sort(List<T> list, Comparator<? super T> c)
The <T>
means that there is a generic T
being used in this declaration. This has two impacts;
T
in the first type of the first argument must match the type in the second argument. (And ? super T
means it must be a super class or interface of T
) Without the use of a generic, there is no way to do this.Collections.<Integer>sort(list, myComparator);