Dictionary class keys() method example


Dictionary class keys()method example. This example shows you how to use keys()method.This method Returns an enumeration of the keys in this dictionary.

Here is the code:-
/**
 * @Program that  Returns an enumeration of the keys in this dictionary.
 * keysDictionary.java 
 * Author:-RoseIndia Team
 * Date:-21-May-2008
 */
import java.util.*;
public class keysDictionary {
 public static void main(String[] args) {
 Dictionary d=new Hashtable();
 //Adding Elements in the HashTable
 d.put("1""RoseIndia");
 d.put("2","Harish" );
 d.put("8","Prakash" );
 //    Returns an enumeration of the keys from this dictionary.
 for (Enumeration e = d.keys(); e.hasMoreElements();)
 System.out.println(e.nextElement());
    }

}

Output of the program:-
key values are: 2 1 8

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US