Java 高階-類

ArrayList:
創建:
ArrayList list = new ArrayList(); 判空:list.isEmpty();
添加:
list.add(Object object);
list.addAll(Collection col);【添加一個集合對象】 長度:list.size();
插入:
list.add(index x,Object object);
list.addAll(index,Collection col); 判存:list.contains(元素值,如"makle");
取值:
list.get(index x);
移除:
list.remove(index x); list.remove(list中的元素);
遍歷:
1、for循環 ; 2、Iterator(遍歷器)【Iterator iterator = list.iterator();
while(iterator.hasNext())
iterator.next();
】 ; 3、增強版的for循環 :for(Object o: list):{}
4、轉換爲數組:Object[] o = list.toArray(); 再遍歷

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章