I have a query on Collections API binary search and sort method declarations.
There is upper bound wildcard use with list
parameter in binarySearch
.
But the list
parameter in the sort
method does not use an upper bound wildcard. Why are these different?
For sort
, list
does not use upper bound wildcard.
static <T> void sort(List<T> list, Comparator<? super T> c)
For binarySearch
, list
uses an upper bound wildcard.
static <T> int binarySearch(List<? extends T> list, T key, Comparator<? super T> c)
I am wondering why upper bound is needed here if it is not needed in the sort
method.