Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
Consider: enum MyEnum { A, B { void foo() { } } } Then: MyEnum.A.getClass().isEnum() ==> true MyEnum.B.getClass().isEnum()) ==> false This is correct and is as specified by JLS 8.9.1. However, it's counterintuitive, as one might reasonably expect enum constants to be instances of the enum class. This isn't the case, as enum constants with method bodies are instances of an anonymous subclass of the enum class, and isEnum() is [correctly] false for such subclasses. This might be worth noting in the Class.isEnum() method doc.
|