enum example 2


public class testdays {

     public enum DaysofWeek {SUN,MON,TUE,WED,THU,FRI,SAT};
   
    public static void main(String[] args) {
       
        DaysofWeek dw= DaysofWeek.MON;
       
     System.out.println("Days of Week : "+ DaysofWeek.valueOf("MON") );
       
     
        System.out.println(dw);
     
         DaysofWeek[] dws = DaysofWeek.values();
       
        for(DaysofWeek dd:dws)
        {
            System.out.println(dd);
        }
       
    }
}

Comments

Popular posts from this blog

Custom Exception example for BankAccount

Annotation

Interface with class and interface as member