import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class For{
public static void main(String[]args) {
//new一个集合对象
List<Object> alList=new ArrayList<Object>();
alList.add(1);//自动转成Integer
alList.add("abc");
alList.add('a');
//一般for循环
for(int i=0;i<alList.size();i++){
System.out.println(alList.get(i));
}
//增强for循环
for(Object x:alList){
System.out.println(x);
}
//Iterator迭代
for(Iterator<Object> al=alList.iterator();al.hasNext();){
System.out.println(al.next());
}
//或者
Iterator<Object> it=alList.iterator();
while(it.hasNext()){
System.out.println(it.next());
}
}
}