This content has been marked as final. Show 4 replies
Integer is a final class, it can not be extended. So, you could as well write:
On the other hand, If you were thinking of a set allowing different kinds of numbers, this is what you might be looking for.
SortedSet<Integer> set = new TreeSet<Integer>(); Comparator<? super Integer> c = set.comparator(); c.compare(new Integer(5), new Integer(5));
Why it must be "super" instead of "extends" is explained by [PECS rule|http://stackoverflow.com/questions/2723397/java-generics-what-is-pecs].
SortedSet<? super Number> set = new TreeSet<Number>(); Comparator<? super Number> c = set.comparator(); c.compare(new Integer(5), new Long(5));