Is there a practical difference between these two signatures:
public static <T extends Comparable<? super T>> T max(Collection<T> c)
and
public static <T extends Comparable<T>> T max(Collection<? extends T> c)
I cannot think of a single use case where these two would not be interchangeable.
Then what is the reason for having both ? super T and ? extends T in the standard max() method in the Java Collections:
public static <T extends Comparable<? super T>> T max(Collection<? extends T> coll)
Edit:
This question is not about the difference between <? super T>
and <? extends T>
. The get/put principle is quite clear to me.
The question is about the difference between these 2 particular signatures and why did the creators of the Java Collections API decided to create a mix out of these two signatures for their standard "max" function.