How to get all enum values in Java?

Call Class#getEnumConstants to get the enum’s elements (or get null if not an enum class).

Object[] possibleValues = enumValue.getDeclaringClass().getEnumConstants();

Leave a Comment