天天看點

JAVA 資料結構(九):Collection接口(三)Collection子接口:List接口

1. 存儲的資料特點:存儲序的、可重複的資料。

2. 常用方法:(記住)

增:add(Object obj)

删:remove(int index) / remove(Object obj)

改:set(int index, Object ele)

查:get(int index)

插:add(int index, Object ele)

長度:size()

周遊:① Iterator疊代器方式

② 增強for循環

③ 普通的循環

3. 常用實作類:

5. 存儲的元素的要求:

添加的對象,所在的類要重寫equals()方法

[面試題]

* 面試題:ArrayList、LinkedList、Vector者的異同?

* 同:三個類都是實作了List接口,存儲資料的特點相同:存儲序的、可重複的資料

* 不同:見上(第3部分+第4部分)