put(Object, Object): This method is available in java.util.Properties class of Java.
Syntax:
Object java.util.Properties.put(Object key, Object value)
This method takes two arguments. This method maps the specified key to the specified value in this hashtable.
Note: Neither the key nor the value can be null.
Parameters: One parameter is required for this method.
key: the hashtable key.
value: the value.
Returns: the previous value of the specified key in this hashtable, or null if it did not have one.
Exceptions: NA
Approach
Java
import java.util.Properties;public class Propertiesput {public static void main(String[] args) {Properties properties = new Properties();properties.put("Hello", "World");properties.put("C++", "Program");properties.put("Java", "Program");System.out.println(properties);}}
Output:
{Java=Program, C++=Program, Hello=World}
No comments:
Post a Comment