Sunday, 8 January 2012

Hashtable

  • Hashtable is collection that stores elements in the form of key-value pairs.
  • If key provided later its corresponding value can be easily retrieved from the Hashtable .
  • Duplicate keys are not allowed but values can be duplicated
  • Insertion order is not preserved and it is based on hashcode of the keys.
  • Heterogeneous objects are  allowed  for key and value
  • Null key or null value is not allowed .otherwise we will get NullPointerException.  
  • It is not Synchronized.but we can synchronized by using method of collection class
                   public staic Map synchronizedMap(Map m);

Constructors:
  • Hashtable m=new Hashtable();//creates an empty Hashtable object with default  initial capacity 11 and default fill ratio 0.75 .fill ratio is also known as Load Faction
  • Hashtable m=new Hashtable(Map m); 
  • Hashtable m=new Hashtable(int initialcapacity); 
  • Hashtable m=new Hashtable(int initialcapacity float fillratio); 

No comments:

Post a Comment