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();

YourEnumClass[] yourEnums = YourEnumClass.class.getEnumConstants();

Or

YourEnumClass[] yourEnums = YourEnumClass.values();