Reputation: 38
Does anyone have a link for the java Comparable<T>
type?
I can only find documentation concerning the interface. I require
information concerning Objects of type Comparable
, not objects that
implement the Comparable
interface.
For example:
Comparable element = "6";
Eclipse allows that expression, although it gives a warning that
it must be parameterized, (i.e. Comparator<T>
). Does anyone have an explanation?
Upvotes: 0
Views: 728
Reputation: 393956
Comparable is an interface, not a class. You can assign the String "6" to a Comparable variable because String implements Comparable<String>
.
Specifying the type parameter will get rid of the warning :
Comparable<String> element = "6";
Upvotes: 4