0

I am learning Java and am puzzled as to the difference between the two following definitions:

public static <T extends Object & Comparable<? super T>>
    T max(List<? extends T> list, int begin, int end) {
   ...
}

(taken from the answer to exercise 8 in the oracle java tutorial: Tutorial) and

public static <T extends Comparable<T>> 
    T max (List<T> list, int begin, int end) {
  ...
}
  • 1
    `Object &` is basically meaningless. – SLaks Oct 26 '15 at 14:02
  • 1
    Depends. Without context yes, but `Collections.max(Collection extends T> coll)` in the official API uses `Object &` as part of its signature to preserve binary compatibility. So it's not always meaningless. – Alexis C. Oct 26 '15 at 14:06

1 Answers1

0

Here, have a look at this thread:

What is <? super T> syntax?

You should see the difference between the two then. Basically the former is more flexible in what you can use as T.

Community
  • 1
  • 1
voiDnyx
  • 975
  • 1
  • 11
  • 24