In Java it is legal to create a comparator object like this:
Comparator<? super Number> comparator = new Comparator<Object>() {
@Override
public int compare(Object o1, Object o2) {
// implementation here
}
};
But you can't use this object for a simple call like this:
Object o1 = new Object(), o2 = new Object();
comparator.compare(o1, o2);
Why so? I thought ? super Number
means Number and all its superclasses.