集合部分:ArrayList集合新增元素,並遍歷元素
集合的新增元素和遍歷
*/
import java.util.*;
class ArrayListTest
{
public static void main(String[] args)
{
System.out.println("Hello World!");
test1();
}
public static void test1()
{
ArrayList al=new ArrayList();
al.add("zhangsan");
al.add("lisi");
al.add("wangwu");
al.add("zhangliu");
System.out.println(al.indexOf("lisi"));
System.out.println("原始集合:"+al);
Iterator it=al.iterator();
while (it.hasNext())
{
System.out.print(it.next());
}
}
}