天天看點

Set ,List,ArrayList,LinkedList,Vectory,HashMap,Hashtable,HashSet,TreeSet,TreeSet

Set與List差別:

  兩者都是接口,并繼承Collection接口;List有序,允許重複;Set無序,不能重複;

ArrayList與LinkList與Vector差別:

    ArrayList和Vector都是使用數組方式存儲資料,此數組元素數大于實際存儲的資料以便于插入和增加元素,它們都允許按序号索引元素,但是插入會涉及到資料元素移動等記憶體操作,是以索引資料快而插入慢,Vector由于使用了Synchronized方法(線程安全),通常性能較ArrayList差,而LinkedList使用雙向連結清單實作存儲,按序号索引資料需要進行前向或後向周遊,但是插入時隻需要記錄本身前後項就可以,是以插入速度較快。

  

HashMap與Hashtable差別:

    實作Map接口;HashMap是線程異步(ArrayList也是),Hashtable是同步的(Vectory也是),可以使用Collections.synchronizedMap方法實作同步;。HashMap允許空鍵值對;

轉載于:https://www.cnblogs.com/IanLan/p/6182241.html