I have enum that implement MyInterface. While making other class using that enum I want to constrain the enumClz to be class that has implemented MyInterface.
So I describe signature to be "T extends Enum< T extends MyInterface>" at generic type declaration.
public <T extends Enum< T extends MyInterface>> C1( Class<T> enumClz) {
for (T anEnumConst : enumClz.getEnumConstants()) {
//....process
}
}
What surprised me is the IDE say it is "unexpected bound" at "T extends MyInterface".
I don't know what it means by such two word error message, Any solution about this?
And by the way, out of curious I have an odd question though not really important. Can an enum type T be equivalent to the following infinite loop
<T extends Enum< T extends Enum<T extends<....>>>> ?
extendswhen used in generic bounds means "is, or extends, or implements".