Java Program to Access All the Constant Defined in the Enum Last Updated : 23 Jul, 2025 Comments Improve Suggest changes Like Article Like Report An enum is a special class that represents a group of constants. To create an enum, use the enum keyword (instead of class or interface), and separate the constants with a comma. enum Day{ SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY; } values() method can be used to return all values present inside enum. We can't see this method in Javadoc because the compiler adds it. The compiler automatically adds some special methods when it creates an enum. For example, they have a static values method that returns an array containing all the enum's values in the order they are declared. So the values() function list all values of the enumeration. Day days[] = Day.values(); for(Day d : days) System.out.print(d); Java // Java program to show the usage of // values() method of java enumeration enum Day{ SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY; } class Main{ public static void main(String args[]) { // Calling values() Day days[] = Day.values(); for(Day d : days) System.out.println( d ); } } OutputSUNDAY MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY Comment More infoAdvertise with us Next Article Java Program to Convert Enum to String K kapilnama1998 Follow Improve Article Tags : Java Java Programs Java-Enumeration Practice Tags : Java Similar Reads Java Program to Convert Enum to String Given an enum containing a group of constants, the task is to convert the enum to a String. Methods: We can solve this problem using two methods: Using name() MethodUsing toString() Method Let us discuss both of them in detail and implementing them to get a better understanding of the same. Method 1 2 min read Java Program to Create ArrayList From Enumeration Enumerations serve the purpose of representing a group of named constants in a programming language. Enums are used when we know all possible values at compile-time, such as choices on a menu, rounding modes, command-line flags, etc. It is not necessary that the set of constants in an enum type stay 2 min read Java Program to Define Ordinal() Method Using Enum Concept Java enum, also called Java enumeration type, is a type whose fields consist of a fixed set of constants. The java.lang.Enum.ordinal() tells about the ordinal number(it is the position in its enum declaration, where the initial constant is assigned an ordinal of zero) for the particular enum. ordina 2 min read Get Enumeration Over Java ArrayList ArrayList class is a re-sizeable array that is present in java.util package. Unlike the built-in arrays, ArrayList can change their size dynamically where elements can be added and removed from an ArrayList. In java version 1, enum was not present. With advancement to version, 1.5 enum was introduce 3 min read Why Enum Class Can Have a Private Constructor Only in Java? Every enum constant is static. If we want to represent a group named constant, then we should go for Enum. Hence we can access it by using enum Name. Enum without a constructor: enum Day{ SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY; } Enum with a constructor: enum Size { SMALL("Th 2 min read Class getEnumConstants() method in Java with Examples The getEnumConstants() method of java.lang.Class class is used to get the Enum constants of this class. The method returns the Enum constants of this class in the form of an array of objects comprising the enum class represented by this class. Syntax: public T[] getEnumConstants() Parameter: This me 2 min read Like