Take as example java.sql.Timestamp. This class extends java.util.Date which implements Comparable<Date>. Therefore, Timestamp also implements Comparable<Date>.
The <? super T> simply takes these classes into account. If you would have limited it to <T extends Comparable<T>> then you could never use Timestamp, or for example any class that would extend Dog.
So a class which directly implements Comparable interface or a class whose super class implements Comparable interface could be passed as a parameter to sort() method.
Rob, please correct me if i am wrong...
A class X that implements Comparable<X> -- in other words, any instance can be compared to any other instance. Or a sub class of such a class.
It's the <X> that's very important. I can write a class that can compare itself to Strings:
Because instances of Test cannot be compared to other instances of Test, only to String, it cannot be used in sort().
Joined: Jul 16, 2010
Thank you so much for your valuable guidance Rob.. I got the point
I want to become stronger in Generics Could you please suggest me any URL where everything about Generics is explained clearly (or) could you suggest me any text book please...