复制代码
- //:Enumerators2.java
- //RevisitingEnumerations
- importjava.util.*;
- classPrintData{
- staticvoidprint(Enumeratione){
- while(e.hasMoreElements())
- System.out.println(
- e.nextElement().toString());
- }
- }
- classEnumerators2{
- publicstaticvoidmain(String[]args){
- Vectorv=newVector();
- for(inti=0;i<5;i++)
- v.addElement(newMouse(i));
- Hashtableh=newHashtable();
- for(inti=0;i<5;i++)
- h.put(newInteger(i),newHamster(i));
- System.out.println("Vector");
- PrintData.print(v.elements());
- System.out.println("Hashtable");
- PrintData.print(h.elements());
- }
- }///:~
欢迎光临 仓酷云 (http://ckuyun.com/) | Powered by Discuz! X3.2 |