1.ArrayList集合中常用的方法

ArrayList<Student> stuArrayList = new ArrayList<>(); //定义一个集合对象

stuArrayList.add();//添加元素

stuArrayList.add(index, e)://在某个位置添加元素,但不覆盖原元素

stuArrayList.get(index)://获取某位置的元素

stuArrayList.size()://获取集合长度

stuArrayList.remove("")://删除某元素

stuArrayList.remove(index)://删除某位置元素

stuArrayList.set(index,e)://用e覆盖某位置元素



2.一个问题点:

ArrayList<String> list = new ArrayList<>();

System.out.println(list);  //打印结果为空,并不是地址址,因为底层作了toString转换。


int []arr = new int[2];

syso(arr)://打印结果为内存地址