In Java, setProperties()
is a static method used to set the argument instance of the Properties
class to current system properties. It is the opposite of getProperties() method.
Note:
java.util.Properties
is a subclass ofHashTable
class containing key and value pairs of string type.
static void setProperties(Properties properties)
setProperties()
takes the parameter, properties
, which represents the instance of Properties
class.
It is a void method. it does not return any value.
import java.lang.*;import java.util.Properties;// Edpresso class to test this methodpublic class Edpresso {public static void main(String[] args) {// Extracting current propertiesProperties property = System.getProperties();// Putting value and key of this propertyproperty.put("java.runtime.version", "Java Runtime v8.1.0");// Calling setProperties() method to set// current system thread propertiesSystem.setProperties(property);// Getting property after "java runtime version" as valueSystem.out.println(System.getProperty("java.runtime.version"));}}
getProperties()
method to extract current system thread’s properties type instance.Click here to learn more about
getProperties()
function and how it works.
setProperties()
method to set the current system thread’s properties.