Java Program to Demonstrate Example of Enum Data Type

Java program to demonstrate example of enum data type

//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
Share on:

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Comment