Java 枚举

 

import java.util.Vector;
import java.util.Enumeration;
 
public class EnumerationTester {
 
   public static void main(String args[]) {
      Enumeration<String> days;
      Vector<String> dayNames = new Vector<String>();
      dayNames.add("Sunday");
      dayNames.add("Monday");
      dayNames.add("Tuesday");
      dayNames.add("Wednesday");
      dayNames.add("Thursday");
      dayNames.add("Friday");
      dayNames.add("Saturday");
      days = dayNames.elements();
      while (days.hasMoreElements()){
         System.out.println(days.nextElement()); 
      }
   }
}

输出

Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday

 

 

 

 

 

posted @ 2019-10-19 18:22  anobscureretreat  阅读(181)  评论(0编辑  收藏  举报