Can someone please explain what this means?
Enum<T extends Enum<T>>
This seems like a circular definition, and I find it highly confusing to say the least.
Can someone please explain what this means?
Enum<T extends Enum<T>>
This seems like a circular definition, and I find it highly confusing to say the least.
There's a good explanation in the Java Generics FAQ.
From the end bit:
To sum it up, the declaration
Enum<E> extends Enum<E>>
can be decyphered as:Enum
is a generic type that can only be instantiated for its subtypes, and those subtypes will inherit some useful methods, some of which take subtype specific arguments (or otherwise depend on the subtype).
(I do sympathise though - recursively generic declarations are a pain. My protocol buffers port to C# is even worse though: it requires two declarations which each refer to themselves and each other... I haven't found a way of simplifying them.)