Home »
Java Programs »
Java Basic Programs
Java program to demonstrate example of enum data type
Enum data type example in Java: In this program, we will learn how enum is declared and how it will be used in a java program?
Enum Data type Example using Java program
//Java program to demonstrate example of enum data type
public class EnumExample
{
//enum type must be global
enum weekDays {SUN, MON, TUE, WED, THU, FRI, SAT}
public static void main(String args[])
{
//print all values
System.out.println("Value of SUN: "+ weekDays.SUN);
System.out.println("Value of MON: "+ weekDays.MON);
System.out.println("Value of TUE: "+ weekDays.TUE);
System.out.println("Value of WED: "+ weekDays.WED);
System.out.println("Value of THU: "+ weekDays.THU);
System.out.println("Value of FRI: "+ weekDays.FRI);
System.out.println("Value of SAT: "+ weekDays.SAT);
}
}
Output
Value of SUN: SUN
Value of MON: MON
Value of TUE: TUE
Value of WED: WED
Value of THU: THU
Value of FRI: FRI
Value of SAT: SAT
Java Basic Programs »