propertyNames(): This method is available in java.util.Properties class of Java.
Syntax:
Enumeration<?> java.util.Properties.propertyNames()
This method 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.
Parameters: NA
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.
Approach
Java
import java.util.Enumeration;import java.util.Properties;public class PropertiespropertyNames {public static void main(String[] args) {Properties properties = new Properties();properties.put("Hello", "World");properties.put("C++", "Program");properties.put("Java", "Program");Enumeration<?> enumeration = properties.propertyNames();while (enumeration.hasMoreElements()) {System.out.print(enumeration.nextElement() + " ");}}}
Output:
Java C++ Hello
No comments:
Post a Comment