J2SE鞏固-集合

跟隨公司大牛一起面試了不少技術人員,有工作3-4年的有工作6年以上的。發現能令我們滿意的太少,因此桌上簡歷是越堆越高。
技術基礎也是面試的基礎,這一關不通過,面試基本就結束。
集合是我們開發過程常用的一種類型,JDK爲我們提供了Collection,Map等集合類型,盜用CSDN一位博主的圖
這裏寫圖片描述
經常用的我們有ArrayList/HashSet/HashMap等,
List重複有序
Set不重複無序
Map提供鍵值對
但我們有時會需要一些特殊需求,比如要求List既有序也不重複,或者Set不重複也有序,Map按key有序輸出,或者線程安全的等。從上面的圖很容易分析出,JDK是有提供這樣能力的api和相應的實現類。
一、List 接口
An ordered collection (also known as a sequence). The user of this interface has precise control over where in the list each element is inserted. The user can access elements by their integer index (position in the list), and search for elements in the list.
Unlike sets, lists typically allow duplicate elements. More formally, lists typically allow pairs of elements e1 and e2 such that e1.equals(e2), and they typically allow multiple null elements if they allow null elements at all。
List能夠精確控制每個被插入的元素的位置,然後通過整數index來獲取。並且允許多個重複元素。
List接口的實現類有
AbstractList, AbstractSequentialList, ArrayList, AttributeList, CopyOnWriteArrayList, LinkedList, RoleList, RoleUnresolvedList, Stack, Vector
常用的有ArrayList LinkedList Vector CopyOnWriteArrayList

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