在输出很多的ArrayList的元素时,用普通的for循环太麻烦,因此本文介绍三种遍历ArrayList的方法 package test; public class Student { private String name; private int age; public Student() { // TODO Auto-generated constructor stub } public String getName() { return name; } public void setNa…
public class ArrayListDemo { public static void main(String args[]){ List<String> list = new ArrayList<String>(); list.add("luojiahui"); list.add("luojiafeng"); //方法1 Iterator it1 = list.iterator(); while(it1.hasNext()){ Sy…