Sunday, February 25, 2018

Java Program : Enumerators example

class Enums1
{
    enum Months{jan,feb,mar,apr,may}
   
    public static void main(String[] args)
    {    Months m=Months.feb;
        System.out.println(m);
    }
}

---------------------------------------------------------

command to compile the program

D:\javaprograms>javac  Enums1.java   <ENTER>

command to run the compiled program

D:\javaprograms>java Emuns1  <ENTER>

You need to save and compile your program each time you make a change in it.
Thanks
Happy programming!

No comments:

Post a Comment

How can I run a C++ program directly from Windows?

How-can-I-run-a-C-program-directly-from-Windows