Signature of Collections.min/max method

Posted by Marco on Stack Overflow See other posts from Stack Overflow or by Marco
Published on 2010-05-25T18:14:22Z Indexed on 2010/05/25 18:21 UTC
Read the original article Hit count: 287

Filed under:
|
|

In Java, the Collections class contains the following method:

public static <T extends Object & Comparable<? super T>> T min(Collection<? extends T> c)

Its signature is well-known for its advanced use of generics, so much that it is mentioned in the Java in a Nutshell book and in the official Sun Generics Tutorial.

However, I could not find a convincing answer to the following question:

Why is the formal parameter of type Collection<? extends T>, rather than Collection<T>? What's the added benefit?

© Stack Overflow or respective owner

Related posts about java

Related posts about generics