public class Demo07 {
public static void main(String[] args) {
ArrayList arr = new ArrayList();
arr.add("tom");
arr.add(3);
arr.add(2);
arr.add(1);
Collections.reverse(arr);
System.out.println(arr);
Iterator it = arr.iterator();
while(it.hasNext()){
Object s = it.next();
System.out.println(s);
}
int[] a = {1,2,3,4};
System.out.println(a);
for (int i = 0; i < a.length; i++) {
System.out.println(a[i]);
}
}
就是为什么集合能直接打印,还要迭代器啊