import java.util.*;
import java.util.Hashtable;
import java.util.Enumeration;
public class HashTableException {
public static void main(String args[]) {
try {
Hashtable hashtable = new Hashtable();
hashtable.put("Girish", new Integer(1));
hashtable.put("Tewari", new Integer(2));
Integer one = (Integer) hashtable.get("One");
System.out.println("Elements in the Hashtable");
Enumeration e = hashtable.keys();
while (e.hasMoreElements()) {
System.out.println(e.nextElement());
System.out.println(e.nextElement());
System.out.println(e.nextElement());
}
} catch (Exception ex) {
System.out.println
("Exception generated by hash table is "+ex.getMessage());
}
}
}
OUTPUT
java.util.NoSuchElementException: Hashtable Enumerator
No comments:
Post a Comment