Related to that question.
I know about wildcard capturing. For instance, the following could be used for reversing a list:
public static void reverse(List<?> list) { rev(list); } //capturing the wildcard
private static <T> void rev(List<T> list) {
List<T> tmp = new ArrayList<T>(list);
for (int i = 0; i < list.size(); i++) {
list.set(i, tmp.get(list.size()-i-1));
}
}
Now I'm trying to write the same thing for that kind of situation:
private int compare (Comparable<?> upper, Comparable<?> lower){
return comp(upper, lower); //The method comp(Comparable<T>, Comparable<T>) is not applicable for the arguments (Comparable<capture#5-of ?>, Comparable<capture#6-of ?>)
}
private <T> int comp(Comparable<T> upper, Comparable<T> lower){
return upper.compareTo((T) lower);
}
I expected that it was compiled fine as well. Is it possible to capture wildacrds for methods with two or more parameters that way?