Properties contains(Object) in Java

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

Syntax:

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

This method takes one argument. This method tests if some key maps into the specified value in this hashtable.

Parameters: One parameter is required for this method.

value: a value to search for.

Returns: true if and only if some key maps to the value argument in this hashtable as determined by the equals method; false otherwise.

Exceptions: NA

Approach

Java

import java.util.Properties;

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

        Properties properties = new Properties();

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

        Object value = "Program";

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

Output:

true


No comments:

Post a Comment