Saturday, July 2, 2011

Hash table exception in java java.util.NoSuchElementException Hashtable Enumerator

Hash table exception in java java.util.NoSuchElementException Hashtable Enumerator





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 = (Integerhashtable.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