Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Enumeration Interface in Java

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 276
    Comment on it

    Enumeration is used to retrieve or traverse all the elements of particular collection of objects. Its not considered for collections but we can use it for legacy like Vectors. To use it we need to import - Java.util.Enumeration


    Below is the implementation :-

      Enumeration enumDay; 
      Vector nameOfEnumDay = new Vector(); 
      nameOfEnumDay.add("Sunday"); 
      nameOfEnumDay.add("Monday"); 
      nameOfEnumDay.add("Tuesday"); 
      nameOfEnumDay.add("Wednesday"); 
      nameOfEnumDay.add("Thursday"); 
      nameOfEnumDay.add("Friday"); 
      nameOfEnumDay.add("Saturday"); 
      enumDay = nameOfEnumDay.elements(); 
      while (enumDay.hasMoreElements()){ 
         System.out.println(enumDay.nextElement());  
      } 
    
    
    } 
    } 
    

    Output :-
    Sunday Monday Tuesday Wednesday Thursday Friday Saturday

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: