Properties keySet() in Java

keySet(): This method is available in java.util.Properties class of Java.

Syntax:

Set<Object> java.util.Properties.keySet()

This method returns a Set view of the keys contained in this map.

Parameters: NA

Returns: a set view of the keys contained in this map.

Exceptions: NA

Approach

Java

import java.util.Properties;

public class PropertieskeySet {
    public static void main(String[] args) {

        Properties properties = new Properties();

        properties.put("Hello", "World");
        properties.put("C++", "Program");
        properties.put("Java", "Program");

        System.out.println(properties.keySet());
    }
}

Output:

[Java, C++, Hello]


No comments:

Post a Comment