Java Collections Framework

Implementations Types

Internal management

Interfaces Hash table Implementations Resizable array Implementations Tree Implementations Linked list Implementations Hash table + Linked list Implementations
Set HashSet - TreeSet - LinkedHashSet
List - ArrayList - LinkedList -
Queue - - - - -
Deque - ArrayDeque - LinkedList -
Map HashMap - TreeMap - LinkedHashMap
Does not throw because of only one element is in collection Throw exception

Fail Fast Iterator Fail Safe Iterator
Examples ArrayList,Vector,HashMap,HashSet CopyOnWriteArrayList,ConcurrentHashMap
Throw ConcurrentModification Exception Yes No
Memory Overhead No Yes
Clone object No Yes
Interface Implementation Class Interface Implementation Class
List
  • AbstractList
  • AbstractSequentialList
  • ArrayList
  • AttributeList
  • CopyOnWriteArrayList
  • LinkedList
  • RoleList
  • RoleUnresolvedList
  • Stack
  • Vector
Set
  • AbstractSet
  • ConcurrentSkipListSet
  • CopyOnWriteArraySet
  • EnumSet
  • HashSet
  • JobStateReasons
  • LinkedHashSet
  • TreeSet
Map
  • AbstractMap
  • Attributes
  • AuthProvider
  • ConcurrentHashMap
  • ConcurrentSkipListMap
  • EnumMap
  • HashMap
  • Hashtable
  • IdentityHashMap
  • LinkedHashMap
Map
  • PrinterStateReasons
  • Properties
  • Provider
  • RenderingHints
  • SimpleBindings
  • TabularDataSupport
  • TreeMap
  • UIDefaults
  • WeakHashMap
Class S Data Default FF Extend RE TEX
HasSet No HashMap<E,Object> map = new HashMap<>() Empty Yes AbstractSet No No
LinkedHashSet No HashMap<E,Object> map = new LinkedHashMap<>() 16 and 0.75 Factor Yes HashSet No No
TreeSet No new TreeMap<E,Object>() Implements -> NavigableMap<E,Object> m Empty Yes AbstractSet No No
AttributeList No Object[] elementData Empty No ArrayList Yes No
ArrayList No transient Object[] elementData Empty Yes AbstractList Yes No
LinkedList No Object[] elementData Empty Yes AbstractSequentialList Yes No
Vector Yes Object[] elementData 10 Yes AbstractList Yes No
TreeMap No
  • transient Entry<K,V> root
  • Entry<K,V> left;
  • Entry<K,V> right;
  • Entry<K,V> parent;
Empty Yes AbstractMap No No
HashMap No
  • transient Node<K,V>[] table
  • transient Set<Map.Entry<K,V>> entrySet;
Empty Yes AbstractMap No No
HashTable Yes Entry<?,?>[] table Empty - 11 and 0.75 Factor Yes Dictionary No No
LinkedHashMap No
  • LinkedHashMap.Entry<K,V> head;
  • LinkedHashMap.Entry<K,V> tail;
Empty Yes HashMap No No
ArrayList LinkedList
Class 1.000.000 Methods

Records: 1 000 000

ArrayList has initialization with default constructor ()

Proccesor I7 2,7Ghz

ArrayList Creation Time: 8 Seconds Memory: 1670

LinkedList Creation Time: 5 Seconds Memory:1730

Records: 2 000 000

ArrayList has initialization with default constructor ()

Proccesor I7 2,7Ghz

ArrayList Creation Time: 15 Seconds Memory: 3300

LinkedList Creation Time: 12 Seconds Memory:3300

Records: 2 150 000

ArrayList has initialization with default constructor ()

Proccesor I7 2,7Ghz

ArrayList Creation Time: 16 Seconds Memory: 3550

LinkedList Creation Time: 12 Seconds Memory:3550

Records: 2 200 000

ArrayList has initialization with default constructor ()

Proccesor I7 2,7Ghz

ArrayList Creation Time: 20 Seconds Memory: 3850

LinkedList Creation Time: 12 Seconds Memory:3650

Records: 2 200 000

ArrayList has initialization with amount (2200000)

Proccesor I7 2,7Ghz

ArrayList Creation Time: 18 Seconds Memory: 3650

Records: 1 000 000, 2 000 000, 2 200 000

Proccesor I7 2,7Ghz

ArrayList and LinkedList iterate for all members in collection

I have done a test of contais Method

ArrayList and LinkedList never reaching to 1 Second

In other words they do not have any difference