Saturday 22 October 2011

Hash map tutorial and Hash map video free download

 Video sample screenshot:

 













Hash Map is like Hashtable which stores key/ value pairs. It implements Map interface and we can use all operations of Map interface. It permits null values and null key. The Hash Map class is almost equivalent to Hashtable, except that its unsynchronized and permits nulls. The order of elements is not guaranteed.

Following is the signature of HashMap class:
Public class HashMap extends AbstractMap implements Map, Cloneable, Serializable

HashMap constructor can be specified with -initial capacity and load factor. The capacity of HashMap gives the storage capacity and size() gives the actual elements present in the HashMap. The intial capacity gives the starting capacity of Hash Map when it is created. The load factor gives at what rate the capacity must be increased when the existing capacity gets exhausted. The default load factor is 0.75

There are four constructors in the class HashMap.

HashMap():
It creates an empty HashMap object with an initial capacity of 10 and default load capacity of 16.

HashMap(int cap):It creates an empty Hash Map object with an intial capacity specified as "cap" and a default load capacity of 16.

HashMap(int cap, float loadfactor): It creates an empty HashMap object with intial capacity specified as "cap" and a load capacity specified as "loadcap".

HashMap(Map m1):It creates a HashMap object with the elements of another Map class specified as "M!"




2 comments: