Java:List,ArrayList和LinkList的區別

1.大學數據結構中ArrayList是實現了基於動態數組的數據結構,LinkList基於鏈表的數據結構數組

2.對於隨機訪問get和set,ArrayList優於LinkList,由於LinkedList要移動指針數據結構

3.對於新增和刪除操做add和remove,LinkList比較佔優點,由於ArrayList要移動數據指針

從上面三點能夠看出:對象

ArrayList和LinkList是兩個集合類,用於存儲一系列的對象引用(references)。例如咱們能夠用ArrayList來存儲一系列的String或者Integer繼承

而List繼承自Collection接口。List是一種有序集合,List中的元素能夠根據索引(順序號:元素在集合中處於的位置信息)進行取得/刪除/插入操做。索引

總結以下:接口

List是一個接口,ArrayList、LinkList繼承與這個接口並實現了它.rem

用的時候,能夠這麼用: List<String> list = new ArrayList<String 等同於 ArrayList<String> list=new ArrayList<String>get

相關文章
相關標籤/搜索