10:29 pm - Monday March 27, 2017

Properties example program using Enumeration propertyNames() method

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

BACK

This Properties example Program using Enumeration<?>  propertyNames() method

Example Program




import java.util.*;

public class PropEnumPropNames {

	public static void main(String[] args) {

		Properties prop = new Properties();

		prop.put("Dhoni", "cricket");

		prop.put("nadal", "tennis");

		prop.put("cena", "wwe");

		Enumeration<?> enumer = prop.propertyNames();

		while (enumer.hasMoreElements()) {

			System.out.println("" + enumer.nextElement());

		}

	}

}

 

Output

cena

Dhoni

nadal

 

Explanation

public Enumeration<?> propertyNames()

Returns an enumeration of all the keys in this property list, including distinct keys in the default property list if a key of the same name has not already been found from the main properties list.

 

Returns:

an enumeration of all the keys in this property list, including the keys in the default property list.

 

Throws:

ClassCastException – if any key in this property list is not a string.

 

See Also:

Enumeration, defaults, stringPropertyNames()

BACK

 

 

Filed in: Z-A All Java Codes

Comments are closed.