In the java.util.Collections
class, the max
method is declared as follows:
static <T extends Object & Comparable<? super T>> T max(Collection<? extends T> coll) {
// impl.
}
My question is, why is the type parameter T
explicitly upper-bounded by Object
?
What would be different if the method were instead declared as:
static <T extends Comparable<? super T>> T max(Collection<? extends T> coll) {
// impl.
}
7