System.setProperties() in Java

System.setProperties(): This method is available in java.lang.System class of Java.

Syntax:

void java.lang.System.setProperties(Properties props)

This method takes one argument of type Properties as its parameter. This method sets the system properties to the Properties argument.First, if there is a security manager, its checkPropertiesAccess method is called with no arguments.

Note: If the argument is null, then the current set of system properties are forgotten.

Parameters: One parameter is required for this method.

props: the new system properties.

Throws:

1. SecurityException - if a security manager exists and its checkPropertiesAccess method doesn't allow access to the system properties.

Approach

Java

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

        System.setProperties(System.getProperties());

        System.out.println("Successfully set property");
    }
}

Output:

Successfully set property


No comments:

Post a Comment