Properties get(Object) in Java

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

Syntax:

Object java.util.Properties.get(Object key)

This method takes one argument. This method returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Parameters: One parameter is required for this method.

key: the key whose associated value is to be returned.

Returns: the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Exceptions: NA

Approach

Java

import java.util.Properties;

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

        Properties properties = new Properties();

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

        Object key = "C++";

        System.out.println(properties.get(key));
    }
}

Output:

Program


No comments:

Post a Comment