I'm pulling my hair apart to figure out why this isn't working. Essentially, I want to create a utility method that uses the binarysearch static method to get the index and insert into the collection. Oddly, this doesn't compile!
public static <C> void binarySearch1(List<? extends Comparable<? super C>> list, C key)
int index = Collections.binarySearch(list, key);
list.add(index, key); // doesn't compile here
The method add(int, capture#3-of ? extends Comparable<? super C>) in the type List<capture#3-of ? extends Comparable<? super C>> is not applicable for the arguments (int, C)