Jave List
List
import java.util.List;
初始化
List<Integer> list = new ArrayList<Integer>();
List<Integer> list = new ArrayList<>();
for (int i = 0; i < 10; i++) {
list.add(i);
}
循环遍历
Iterator it1 = list.iterator();
while (it1.hasNext()) {
System.out.println(it1.next());
}
for (Iterator it2 = list.iterator(); it2.hasNext();) {
System.out.println(it2.next());
}
方式 3:
for (Integer temp : list) {
System.out.println(temp);
}
方式 4:
for (int i = 0; i < list.size(); i++) {
System.out.println(list.get(i));
}