This section describes the complete Hash Table implementation from the basic in Java.
Ads
TutorialsThis section describes the complete Hash Table implementation from the basic in Java. In this section, you will see how to store some information and retrieve when it need to search for checking whether the given title exists or not. This section is very helpful for your java application for which the following program supports for working the software in very efficient manner.
Program Description:
Here, an example with complete code is provided for the best illustration of the way of hash table manipulation in Java. How to put some elements with or without any description and retrieve easily when it need. Given program is based on the management of CDs of songs having song's title and singers name of the song. Whenever one needs to search the CD from the title and get whether the given CD's name exists or not in the your stock can be managed by the Hash Table.
Code Description:
HashTable.put(Object key, Object value):
This method of the HashTable class helps to store some
elements with appropriate description. This method takes two arguments one is
the key of the hash table and another is the value corresponding to the specified key.
HashTable.containsKey(Object key):
This is also the method of the HashTable class which is used for
checking whether the specified key (passed as a parameter of the method) exists
or not in the hash table. This method returns the boolean value either true
or false on the basis of the existence of the key in the hash table.
Here is the code of the program:
import java.util.*;
|
Posted on: April 16, 2007 If you enjoyed this post then why not add us on Google+? Add us to your Circles
Advertisements
Ads
Ads
Discuss: Simple Hash Table implementation in Java View All Comments
Post your Comment