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

generics, java

Solution

To preserve binary compatibility: It's completely described here. The second signature actually changes the return type of the method to `Comparable` and it loses the generality of returning an `Object`. The original signature preserves both.

Problem

The signature of java.util.Collections.max looks like this: public static <T extends Object & Comparable<? super T>> T max(Collection collection); From what I understand, it basically means that T must be both a java.lang.Object and a java.lang.Comparable<? super T>>, However, since every java.lang.Comparable is also an java.lang.Object, what is the difference between the signature above and this below? : public static <T extends Comparable<? super T>> T max(Collection collection);

Original source

Related problems