Collections
Set - No duplicate elements
List - Dynamic Array
Map – key value pair - No duplicate keys - Not extended from collection interface
Iterator helps traversing thru the collection. It allows deletion of elements.
Iterator Enumeraton
Twice as fast
Less memory
Thread safe
Allow delete on collection elements
Iterator List Iterator
Can be used with sets and List Specific to lists
Ony frwrd direction traversal Both directions
Add / replace elements
Iterator : fail fast. The next element on iterator will always check for change in collection data, if it
happens, it throws exception. ConcurrentModificationException
Fail Safe – don’t throw exception
Collection view on map : Set KeySet Collection Values()
Hash Map Hash Table
Allows null No null
Synchronised - good for multithreading
Fail fast Not fail fast.
Vector Array list
Synchronised Not synchronized
Slow Fast
Vector, Hashtable, Properties and Stack are synchronized classes
Concurrent collection classes: Fail safe
CopyOnWriteArrayList, ConcurrentHashMap, CopyOnWriteArraySet
Comparable interface - self sorting - compareTo(T obj) – invoked by this.
Comparator : [Link](Object o) – we can implement
multiple logics to compare.
[Link](Collection c) the receiving
functions will not beable to modify it