<T extends Object & E> vs <T extends E>

The signature of java.util.Collections.max is as follows:

public static <T extends Object and Comparable <? super T → T max (collection collection);

From what I understand, this basically means that T should be both java.lang.Object and java.lang.Comparable <? super T "> ,

However, since each java.lang.Comparable is also java.lang.Object , what is the difference between the signature above and below?

public static <T extends Comparable <? super T → T max (collection collection);

+28
java generics
Apr 26 '12 at 18:33
source share
1 answer

To preserve binary compatibility : it is fully described here . The second signature actually changes the return type of the method to Comparable and loses the Comparable return of Object . The original signature saves both.

+28
Apr 26 '12 at 18:42
source share



All Articles