Thursday, February 4, 2016

Java + How to create Synchronized Map ?

Hash Map class Structure

Class HashMap

java.lang.Object

java.util.AbstractMap

java.util.HashMap

Creating SynchronizedMap

Map m = Collections.synchronizedMap(new HashMap(...));

Points to remember about HashMap

1) Permits null values and the null key. 

2) HashMap class is equivalent to Hashtable, except that it is unsynchronized and permits nulls.

3) It does not guarantee that the order will remain constant over time

4) An instance of HashMap has two parameters that affect its  performance: initial capacity and      

    load factor. 

5) The capacity is the number of buckets in the hash table, and the initial capacity is simply the   

    capacity at the  time the hash table is created. 

6) The load factor is a measure of how full the hash table  is allowed to get before its capacity is 

    automatically increased.


No comments:

Post a Comment