Hi ,
I am having a hashtable which consists of some keys and values.I can able to get the information from the hashtable using iterator or Enumeration.
import java.util.*;
import java.util.Hashtable.*;
import java.util.Iterator.*;
import java.util.Enumeration.*;
import java.io.*;
class ex_hashtable
{
public static void main(String args[])throws IOException{
Hashtable<Integer,String> hobj=new Hashtable<Integer,String>();
hobj.put(1,"one");
hobj.put(2,"two");
System.out.println("The size of the hashtable size is "+hobj.size());
Iterator iobj=hobj.keySet().iterator();
while(iobj.hasNext()){
System.out.println("hai");
iobj.next();
}
}
}
In Iterator declaration.
What is the purpose of using the keySet() in the iterator?
What is keySet()?
Iterator iobj=hobj.keySet().iterator();
Thank you,
With Regards,
prem