Core Java Tutorial

Core Java Tutorial

Hashtable Example program for entrySet()

[java]
/**
Author :candidjava.com
Description: Returns a Set view of the entries contained in this Hashtable
*/
import java.util.*;
import java.util.Hashtable;
import java.io.IOException;
public class HashtableEntrySetExample
{
public static void main(String args[])throws IOException
{
int s=33, s1=44,s2=55;
Hashtable h=new Hashtable();
h.put(1,s);
h.put(2,s1);
h.put(3,s2);
h.entrySet(); //returns the set of values given in the hash table
System.out.println(h);
}
}
[/java]

Output :
{3=55, 2=44, 1=33 }