Saturday, April 6, 2013

Synchronized and Unsynchronized Types in Java

TypesSynchronizedUnsynchronized
HashtableY-
HashMap-Y
VectorY-
ArrayList-Y
StringBufferY-
StringBuilder-Y

Hashtable & HashMap & HashSet

Hashtable
  1. A table of records
  2. Stores key-value pairs
  3. Implements Map interface
  4. Does not allow null key
  5. Does not allow null values
  6. Synchronized

HashMap
  1. Stores key-value pairs
  2. Implements Map interface
  3. Allows null key (at most one)
  4. Allows null values (arbitrary number)
  5. Unsynchronized

HashSet
  1. A collection of elements
  2. Implements Set interface
  3. Allows null element (at most one)
  4. Unsynchronized