Properties Enumeration keys() method Example Program


Returns an enumeration of the keys in this hashtable.

Program

package com.candidjava;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Properties;

/* 
 * @author : Mohan 
 * @description : The keys() method is used to get an enumeration of the keys in this hashtable.
 */
public class PropertiesKeys {
	public static void main(String[] args) {
		Properties properties = new Properties();
		Hashtable ht = new Hashtable(properties);
		ht.put("1", "hari");
		ht.put("2", "anand");
		ht.put("3", "vinoth");
		ht.put("4", "mohan");
		ht.put("5", "karthick");
		System.out.println(ht);
		Enumeration en = ht.keys();
		while (en.hasMoreElements()) {
			System.out.println(en.nextElement());
		}
	}
}

Output

{5=karthick, 4=mohan, 3=vinoth, 2=anand, 1=hari}
5
4
3
2
1

Explanation

public Enumeration<K> keys()
Returns an enumeration of the keys in this hashtable.
Specified by:
keys in class Dictionary<K,V>
Returns:
an enumeration of the keys in this hashtable.
See Also:
Enumeration, elements(), keySet(), Map


Related Post

Comments


©candidjava.com