想使用ArrayList首先需要import java.util.ArrayList;
實例化:
ArrayList<Object> arrayList = new ArrayList<Object>();
常用方法:
ArrayList根類為collection,所以ArrayList可以使用collection中定義的方法
如:
add(); 添加對象 如:arrayList.add("a");
get(); 獲取arrayList中的下標對象 如:arrayList.get(1);
size(); 獲取arrayList中的元素個數 如:arrayList.size();
remove(); 刪除arrayList中的某個下標對象 如:arrayList.remove(1);