Java List. Iterator () method: iterates over the list elements
•
Java
iterator()
Typical application
public static void main(String[] args){
List<String>list = new ArrayList<String>(); //定义List集合对象list.add("保护环境"); //向列表中添加数据
list.add("爱护地球"); //向列表中添加数据
list.add("从我做起"); //向列表中添加数据
Iterator it = list.iterator(); //获取Iterator对象
while(it.hasNext()){ //循环遍历Iterator对象
System.out.println(it.next()); //输出Iterator对象中的值
}
}
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
