Reputation: 1153
Usually, when a class implements Comparable
, the type variable T
is the class name, for example, String
implements Comparable<String>
, Long
implements Comparable<Long>
, Date
implements Comparable<Date>
,then why Enum
implements Comparable<E>
not Comparable<Enum<E>>
?
Upvotes: 1
Views: 279
Reputation: 20520
It's because the enum
class is defined as
public abstract class Enum<E extends Enum<E>> ...
So the E
is already an Enum<E>
, and having it implement Comparable<E>
already implicitly has the Enum
part inside it.
You might want to look at this question for further information on why it's declared in this recursive fashion (because it does rather hurt the brain).
Upvotes: 0
Reputation: 533660
E
is an Enum<E>
already.
The reason it cannot be Enum<E>
as that implies any Enum<E>
is comparable which only E
is acceptable.
Upvotes: 2