I am writing a generic class
public class SomeClass<T> {
public static <T extends Comparable<? super T>> T min(Collection<? extends T> c) {
T min = c.iterator().next();
for (T element : c)
if (element.compareTo(min) < 0)
min = element;
return min;
}
}
public class Main {
public static void main(String[] args) {
SomeClass<Integer>.min(Arrays.asList(1, 2, 3));
SomeClass.min(Arrays.asList(1, 2, 3));
}
}
In a generic class SomeClassand generic method, is SomeMethodthe type parameter Tthe same or differentiation?
Why are we compiling a temporary error in a string SomeClass<Integer>.min(Arrays.asList(1,2,3));?
user2889159
source
share