ADVERTISEMENT
ADVERTISEMENT

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 »


ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.