How to find out which enums are defined by a class?

I know that I can get public static members of the class by doing something like:

obj.getClass().getFields()

but it does not give me a listing. I would like to get them from the class object returned by the getClass method. Any ideas?

+3
source share
2 answers

(The inclusion in the community wiki, as it looks like there is an opportunity for significant expansion, for example, to include comments on the game. It makes no sense for me to simply decode the comments when everyone can expand it.)

, ? , Class.getDeclaredClasses() , - . - Class.isEnum(); , Class.getEnumConstants() - .

+6

obj.getClass(). GetEnumConstants()

+1

Source: https://habr.com/ru/post/1698189/


All Articles