Q:

Java program to demonstrate example of enum data type

belongs to collection: Java Basic Programs

0

Java program to demonstrate example of enum data type

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Java Basic Programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Java program to demonstrate example of this keywor... >>
<< Java program to check whether year is Leap year or...