记得导包
1.数据类型<集合存储的数据类型> 变量名 =new 数据类型<集合存储的数据类型> ();
ArrayList<String> array=new ArrayList<String>();
注意:集合只存储引用类型,不存储基本类型!!!!
eg: ArrayList<Integer>
ArrayList<Person> p //Person为自定义的类型
集合中方法:
add(Object obj)
get(int index)
size() //返回集合长度
add(int 索引,存储元素) //将元素添加到指定的索引上,原来位置上的往后移
set(int索引,修改后的元素)
remove(索引)
clear()//清空
集合作为参数:
eg: ArrayList<Student> array=new ArrayList<Student>();
声明方法 public static void add(ArrayList<Student> array);
调用方法 add(array);