SimpleBindings put() method in Java with Examples
The put() method of SimpleBindings class is used to add the specified key and value pair in the SimpleBindings object. Both key and value are passed as parameters. The key renamed as a name for the value to set in SimpleBindings object. After setting the value method returns the previous value for the specified key and it will return null if the key was previously unset.
public Object put(String name, Object value)
Parameters: This method accepts two parameters:
- name which is Name of value and
- value which is the Value to set.
Return Value: This method returns the previous value for the specified key and it will return null if the key was previously unset.
Exception: This method throws following exceptions:
- NullPointerException: if the specified name is null
- IllegalArgumentException: if the specified name is empty String
Java programs to Illustrate the working of put() method:
Key1: value1 Key2: value2 Key3: value3
India Sri Lanka Pakistan Bangladesh