Hash Table Algorithm
Hello friends, today I will take you through some of the basic Hash Table functions .
Lets see how we can do the following using a Hash Table:
- Creating an Instance of a Hash Table
- Adding Keys and Values to the Hash Table
- Feching/Getting thhose Keys and Values from the Hash Table
1. First of all you will need to import java.util.Hashtable
2. Then Create a Class
3. Define the main() method as Static .
4. Create the instance of Hash Table with following Syntax
5. Add Key , Value pair to the Hash Table using the following code
NameofHashTable .put(KEY , VALUE) ;
6. Fetch the VALUE from the Hash Table by telling the KEY whose value you want to get .
Suppose you want to get the VALUE "First Inserted" then ,
NameofHashTable .get(KEY) i.e
7. Similarly, if you want to remove a VALUE from the hash table, you will have to specify its KEY.
NameofHashTable .remove(KEY) i.e
Friends, please feel to write in for any suggestions , or post you comments here .