setProperty(String, String): This method is available in java.util.Properties class of Java.
Syntax:
Object java.util.Properties.setProperty(String key, String value)
This method takes two arguments. This method calls the Hashtable method put.
Parameters: Two parameters are required for this method.
key: the key to be placed into this property list.
value: the value corresponding to the key.
Returns: the previous value of the specified key in this property list, or null if it did not have one.
Exceptions: NA
Approach
Java
import java.util.Properties;public class PropertiessetProperty {public static void main(String[] args) {Properties properties = new Properties();properties.put("Hello", "World");properties.put("C++", "Program");properties.put("Java", "Program");String key = "Joy", value = "Enjoy";System.out.println(properties.setProperty(key, value));}}
Output:
null
No comments:
Post a Comment