// 创建集合对象
ArrayList array = new ArrayList();
ArrayList array = new ArrayList();
//创建元素,并添加元素
array.add("hello");
array.add("world");
//遍历
方法1:迭代器:hasNext()+next()
Iterator it = array.iterator();
while(it.hasNext()){
String s = (String)it.next();
System.out.println(s);
}
方法2:size()+get()
for(int x=0;x<array.size();x++){
String s = array.get(x);
System.out.println(s);
}
for(int x=0;x<array.size();x++){
String s = array.get(x);
System.out.println(s);
}