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

What is a data structures

  Data structure is a tool in the hands of a programmer for  storing a large number of data items  in the main memory (RAM) of a computer wh...