1.Basic java example program to iterate keys of hashtable
  • Enumeration elements()   This method used to get values of hashmap

  1. package com.iteartekeysHashtable;
  2.  
  3. import java.util.Hashtable;

  4. import java.util.Enumeration;
  5.  
  6. public class HashtableExample{
  7.  
  8. public static void main(String[] args) {
  9.   
  10.  //create Hashtable object
  11.        Hashtable<String,String> hashtable = new Hashtable<String,String>();
  12.        
  13. //add key value pairs to Hashtable
  14. hashtable.put("1","Java Interview Questions");
  15. hashtable.put("2","Java Interview Programs");
  16. hashtable.put("3","Concept and example program");
  17. hashtable.put("4","Concept and interview Questions");
  18. hashtable.put("5","Java Quiz");
  19. hashtable.put("6","Real time examples");
  20.  
  21.  
  22.  
  23. Enumeration e=hashtable.elements();
  24.           
  25.  
  26.            
  27. // display search result
  28.  while (e.hasMoreElements()) {
  29.         System.out.println(e.nextElement());
  30. }    

  31. }
  32.  
  33. }
     



Output:

  1. Real time examples
  2. Java Quiz
  3. Concept and interview Questions
  4. Concept and example program
  5. Java Interview Programs
  6. Java Interview Questions

Instance Of Java

We will help you in learning.Please leave your comments and suggestions in comment section. if you any doubts please use search box provided right side. Search there for answers thank you.
«
Next
Newer Post
»
Previous
Older Post

No comments

Leave a Reply

Select Menu