標籤:自己 ast 集合架構 下標 索引 family remove nal 包含
本節內容總結來自傳智播客畢向東老師的公開課,感謝畢向東老師 !如有錯誤之處,歡迎大家指教 !
Collection集合常用方法:
增加、刪除、大小、包含(,包含所有)、為空白、清空、迭代、並交差;
boolean add(E o); boolean remove(Object o); int size(); boolean contains(Object o); boolean isEmpty(); void clear(); Iterator<E> iterator();
boolean addAll(Collection c); boolean retainAll(Collection c); boolean removeAll(Collection c);
Set集合常用的方法:
與Collection集合擁有的方法一樣;
List集合常用的方法:
List集合的方法中,帶索引參數(角標)的都是新增的方法;帶角標的操作都是數組原理;
除了繼承Collection集合的方法,還有以下自己專屬的方法,都與索引(下標)有關:
增加、刪除、修改(只能是修改,不能是插入)、尋找(擷取)元素、尋找元素所在位置(兩種);
void add(int index, E e); E remove(int index); E set(int index, E e); E get(int index); int indexOf(Object o); int lastIndexOf(Object o);
Map集合常用的方法:
增加、刪除、修改、尋找(擷取)、大小、包含、為空白、清空、迭代
V put(K k, V v); V remove(Object k); put()方法也起到修改功能 V get(Object k); int size(); boolean containsKey(Object k);
boolean containsValue(Object v); boolean isEmpty(); void clear();
Java集合架構的學習