Explain the generics used in an Enum ad

Can someone explain what this means?

Enum<T extends Enum<T>> 

This seems like a circular definition, and I find it very confusing, to say the least.

+4
source share
1 answer

There's a good explanation on Java Generics FAQs .

From the end of the bit:

To summarize, the declaration Enum<E> extends Enum<E>> can be decoded as: Enum is a generic type that can only be created for its subtypes, and these subtypes inherit some useful methods, some of which are specific subtype arguments (or otherwise depends on subtype).

(I really sympathize - recursive generic declarations are a pain. My protocol buffers a port in C # even worse: two declarations are required, each of which refers to itself and to each other ... I have not found a way to simplify them.)

+6
source

All Articles