Privacy Policy Terms Of Use. Copyright © 2006-2010 Java Tutorials and Examples.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
A collection allows a group of objects to be treated as a single unit. Map is one of the core interfaces of java collection framework that defines operations for maintaining mappings of keys to values.
Map interface does not implement Collection interface, because it does not contain elements but contains entries of keys and their corresponding values (i.e. called mapping).
Map does not allow duplicate keys. So there is utmost one value that is mapped with the given key. Both key and value must be an Object (Primitive values must be wrapped).
Hashtable implements Map interface (As of the Java 2 platform v1.2, this class has been retrofitted to implement Map, so that it becomes a part of Java's collection framework).
Hashtables will automatically grow when you add too many elements. However, growing requires copying, rehashing and rechaining, which affects its overall performance.
Performance of Hashtable depends on two important factors that are
• Initial Capacity and
• Load Factor
Initial Capacity is the capacity at the time the hash table is created. Load factor determines when to increase the capacity of the Hashtable. The default load factor is 0.75.
Important Note: The initial capacity is not the actual number of elements you plan to store in hashtable. Say for example, if you set initial capacity of 100 and the load factor is 0.75, then the capacity of Hashtable will be automatically increased when it reaches to 75 not 100.
Hashtable Constructor >>

to read more about Hashtable
Post new comment