remove(Object, Object): This method is available in java.util.Properties class of Java.
Syntax:
boolean java.util.Properties.remove(Object key, Object value)
This method takes two arguments. This method removes the entry for the specified key only if it is currently mapped to the specified value.
Parameters: Two parameters are required for this method.
key: key with which the specified value is associated.
value: value expected to be associated with the specified key.
Returns: true if the value was removed.
Exceptions: NA
Approach
Java
import java.util.Properties;public class Propertiesremove2 {public static void main(String[] args) {Properties properties = new Properties();properties.put("Hello", "World");properties.put("C++", "Program");properties.put("Java", "Program");Object key = "Hello", value = "World";System.out.println(properties.remove(key, value));}}
Output:
true
No comments:
Post a Comment