I’m just now realizing their power and utility over using a Constants class… but I’m very interested to know how they’re implemented under the hood. They seem to work alot like a static method or static constant in that you just import the file that “owns” the enum and you can make reference to them by using enumName.valueName. The Javadocs online seem to suggest they’re a class but it seems weird to have an “unnamed” class on demand. (In Java at least…)
I’m just now realizing their power and utility over using a Constants class… but
Share
i believe each instance of the enum is an anonymous final subclass of the enum.
decompile:
and you can see the instances being made: