java中的iterator怎么用

如题所述

Collection coll = new Vector(); //LinkedList(); //ArrayList();  
coll.add("Tody");  
coll.add("is");  
coll.add("Sunday.");  
  
// Output all elements by iterator  
Iterator it = coll.iterator();  
while(it.hasNext()) {  
    System.out.print(it.next() + " ");  
}

温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答
大家正在搜