Article: Hashtable

iSnare.com - Free Content Articles Directory
Authors Contents [Advanced Search][Add OpenSearch][Job Search]
Distribute your articles to thousands of article sites for only $2 and below! Read more...

Index  Computers and Technology
 

Hashtable

 
[ Contact the Author] [ Send to a Friend] [ Article Publisher] [Make PDF] [ Print] [ Bookmark & Share]
 
Read our Terms of Service before reprinting this article. The submitter specified above has claimed the rights to this article.
Rahim Vindhani

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.

Constructors

Hashtable ()
Constructs empty hashtable with a default initial capacity 11 and load factor 0.75.

Hashtable (int initialCapacity)
Constructs empty hashtable with the specified initial capacity and default load factor 0.75.

Hashtable (int initialCapacity, float loadFactor)
Constructs empty hashtable with the specified initial capacity and the specified load factor.

Hashtable (Map t)
Constructs a new hashtable with the mappings same as the passed Map.

Basic methods

Object get (Object key)
Returns the value mapped to the specified key, or null if no entry is found.

Object put (Object key, Object value)
Maps the specified key to the specified value in this hashtable and returns the value previously associated with the specified key, if any. Otherwise, it returns the null value.

Object remove (Object key)
Removes the key and its associated value from the hashtable, and returns the value previously associated with the specified key, if any. Otherwise, it returns the null value.

boolean containsKey(Object key)
Returns true if the specified key is mapped to some value in the map, otherwise false.

boolean containsValue(Object value)
Returns true if there are one or more keys mapped to the specified value, otherwise false.

int size()
Returns the size of the hashtable.

boolean isEmpty()
returns true if hashtable is empty, otherwise false.

Other methods

void putAll(Map t)
copies all mappings from the map to current hashtable and replaces existing entries, if any.

Void clear()
Removes all mappings from hashtable.

Collection values()
Returns collection of the values contained in the hashtable.

Enumeration elements()
Return Enumeration of the values contained in the hashtable.

Set entrySet()
Returns a Set of entries contained in the Hashtable.

Enumeration keys()
Return Enumeration of keys contained in the hashtable.

Object clone()
Creates copy of the hashtable.

Note : hashtable may throw IllegalArgumentException, if any unsupported operation is invoked.

Important NoticeDISCLAIMER: All information, content, and data in this article are sole opinions and/or findings of the individual user or organization that registered and submitted this article at Isnare.com without any fee. The article is strictly for educational or entertainment purposes only and should not be used in any way, implemented or applied without consultation from a professional. We at Isnare.com do not, in anyway, contribute or include our own findings, facts and opinions in any articles presented in this site. Publishing this article does not constitute Isnare.com's support or sponsorship for this article. Isnare.com is an article publishing service. Please read our Terms of Service for more information.

Article Tags: capacity [See Dictionary], hashtable [See Dictionary], key [See Dictionary]
Got a question about this article? Ask the community!
Article published on January 10, 2006 at Isnare.com
 
Rate this article:

Assertion In Java
Submitted by: Rahim Vindhani

Assertion facility is added in J2SE 14...

Java Arrays
Submitted by: Rahim Vindhani

Array is a fixed number collection of elements having same data type In java array is an object...

String In Java
Submitted by: Rahim Vindhani

Handling character strings in Java is supported through two final classes: String and StringBuffer The String class implements immutable character strings, which are read-only once the string has been created and initialized, whereas the StringBuffer class implements dynamic character strings...

Reverse Cell Phone Lookup - Did You See a Number on Your Spouse's Cell You Did Not Recognize?
Submitted by: J Williams-Foster

Reverse cell phone lookup services can provide information about phone number owners for a myriad of reasons, one reason that's not always considered is in the area of love...

How to Dispose of a Multifunction Printer
Submitted by: Derek Rogers

As with most electrical equipment, your printer is full of plastics, components and potentially hazardous materials...

Camcorder Recording Methods and Technology
Submitted by: Allen Roberts

Over the years, camcorders have evolved from tape (which has spanned many decades), to DVD, and more recently to Harddrives(HDD) and Flash Memory...

Valuing Your Entertainment With the LED LCD TV
Submitted by: RahXephon NeO

If you are looking into the latest technology for entertainment, then considering a LED LCD TV may be the best alternative...

Reviewing the Akiles DuoMac 531 Combination 5:1 Pitch Coil and 3:1 Pitch Wire Binding Machine
Submitted by: Jeff McRitchie

As the only binding machine on the market with its particular set of features and options, the Akiles DuoMac 531 appears to hope that its versatility will provide binding solutions for businesses that want flexibility in their document production...

Akiles DuoMac 521 Combination Binding Machine Review
Submitted by: Jeff McRitchie

The Akiles DuoMac 521 presents the market with some nice versatility, although in an unusual combination of binding styles...

Reviewing the Akiles DuoMac 541 Combination 5:1 and 4:1 Pitch Spiral Coil Binding Machine
Submitted by: Jeff McRitchie

The Akiles DuoMac 541 is a unique binding machine in that it allows users to produce documents with both a four to one and five to one pitch binding...

Reviewing the Akiles DuoMac C51 Plastic Comb and 5:1 Pitch Coil Combination Binding Machine
Submitted by: Jeff McRitchie

Uniquely positioned as the only 5:1 pitch combo binding system on the market, the Akiles DuoMac C51 is presented as a solution for businesses that want the ability to do a variety of binding styles all on one machine...

Reviewing the Akiles Megabind 1E Plastic Comb Binding Machine
Submitted by: Jeff McRitchie

An electric comb binder that is meant for medium sized organizations and daily use, the Akiles Megabind 1E includes some features that smaller binding systems don't...

Reviewing the Akiles Offibind 21D Plastic Comb Binding Machine
Submitted by: Jeff McRitchie

As the smallest of Akiles' comb binding systems, the Offibind 21D is intended for use in small or home offices, or for businesses on a very tight budget...

Reviewing the Akiles OffiWire Wire-O Binding Machine
Submitted by: Jeff McRitchie

Presented as a small or home office solution for light duty binding, the Akiles OffiWire comes in 3:1 or 2:1 pitch versions...

Reviewing the Akiles Roll-A-Coil Electric Spiral Coil Inserter
Submitted by: Jeff McRitchie

Seeking to offer the marketplace a lot of features for a low price, the Akiles Roll @ Coil is uniquely positioned in the world of electric coil inserters...

Akiles WireMac Duo Combo Review
Submitted by: Jeff McRitchie

It seems that Akiles has looked to fill a gap in the marketplace with the WireMac Duo As the only machine available to consumers that can bind documents with either a two to one or three to one pitch hole pattern, the WireMac Duo offers users some unprecedented flexibility...

Win Free Laptop—The Real Story Behind
Submitted by: Jason Main

Laptops have become an essential for anyone these days Gone are the days when people would rather choose desktop computers than laptops...

Reverse Phone Lookup - Find the Owner of a Cell Or Landline Phone Number
Submitted by: J Williams-Foster

We've all received phone calls from numbers we didn't recognize Sometimes you may miss calls, and you want to speak to the person again...

Isnare.com Footer Divider

© 2004-2009. Isnare Free Articles - An Isnare Online Technologies Free Articles Project. All Rights Reserved.   Privacy Policy