I have an enumeration that implements MyInterface. When creating another class using this enumeration, I want to restrict enumClz to the class that implemented MyInterface.
Therefore, I describe the signature as " T extends Enum< T extends MyInterface> " when declaring a generic type.
public <T extends Enum< T extends MyInterface>> C1( Class<T> enumClz) { for (T anEnumConst : enumClz.getEnumConstants()) {
What surprised me was that the IDE says it is "unexpectedly associated" with " T extends MyInterface ". I do not know what this means with the help of such a message with two messages. Any decision on this?
And by the way, of the curious, I have a strange question, although not a very important one. Can the enumeration type T be equivalent to the next infinite loop
<T extends Enum< T extends Enum<T extends<....>>>> ?
java generics enums
WeiChing Lin
source share