64. Hashtable class in JAVA
//Hashtable class
import java.util.*;
class HashtableDemo
{
public static void main(String[] args) {
Hashtable obj = new Hashtable();
obj.put("Apple", "Red");
obj.put("Banana", "Yellow");
System.out.println("The color of Apple is : " + obj.get("Apple"));
Enumeration e = obj.keys();
while(e.hasMoreElements())
{
String k = e.nextElement().toString();
String v = obj.get(k).toString();
System.out.println("\tkey : " + k + "\tValue : " + v);
}
}
}
OUTPUT:
The color of Apple is : Red
key : Apple Value : Red
key : Banana Value : Yellow
Comments
Post a Comment