Properties containsValue(Object) in Java

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

Syntax:

boolean java.util.Properties.containsValue(Object value)

This method takes one argument. This method returns true if this hashtable maps one or more keys to this value.

Parameters: One parameter is required for this method.

value: value whose presence in this hashtable is to be tested.

Returns: true if this map maps one or more keys to the specified value.

Exceptions: NA

Approach

Java

import java.util.Properties;

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

        Properties properties = new Properties();

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

        Object value = "World";

        System.out.println(properties.containsValue(value));
    }
}

Output:

true


No comments:

Post a Comment