example8_5.java
来自「《Java程序设计与应用》-张仕斌-源程序 《Java程序设计与应用》-张仕斌」· Java 代码 · 共 37 行
JAVA
37 行
/*
* Example8_5.java
*
* Created on 2006年9月16日, 上午11:17
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package example8_5;
import java.util.*;
/**
*
* @author Administrator
*/
public class Example8_5 {
/** Creates a new instance of Example8_5 */
public Example8_5() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
ArrayList cats=new ArrayList();
for(int i=0;i<7;i++)
cats.add(new Cat(i)); //将对象添加到列表的最后
Iterator e=cats.iterator(); //返回一个iterator对象
while(e.hasNext()) //检查集合中是否还有其他元素
((Cat)e.next()).print(); //得集合中的下一个元素
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?