Hi ,
I have implemented the Hashtable and enumeration concepts in java.The program is executed fine but i have a doubt.When i try to print the keys and elements in the Hashtable by using enumeration ,it start prints from the second key and second element.
Did any one know why it should not start printing from the first key and element.
import java.io.*;
import java.util.Hashtable;
import java.util.Enumeration;
class Hashtable_Program
{
public static void main(String args[])throws IOException
{
System.out.println("Sample hash table program functionlaity");
Hashtable Sample_Table=new Hashtable();
int Table_Value;
Sample_Table.put("First",1);
Sample_Table.put("Second",2);
Sample_Table.put("Third",3);
System.out.println("The size of the hash table is "+Sample_Table.size());
//Enumeration
Enumeration e=Sample_Table.keys();
while(e.hasMoreElements()){
System.out.println("The hashtable keys are "+e.nextElement());
}
e=Sample_Table.elements();
while(e.hasMoreElements()){
System.out.println("The hashtable elements are "+e.nextElement());
}
}
}
output:
The size of the hash table is 3
The hashtable keys are Second
The hashtable keys are Third
The hashtable keys are First
The hashtable elements are 2
The hashtable elements are 1
The hashtable elements are 3
Thank you,
prem