containsValue(Object): This method is available in java.util.LinkedHashMap class of Java.
Syntax:
boolean java.util.LinkedHashMap.containsValue(Object value)
This method takes one argument. This method returns true if this map maps one or more keys to the specified value.
Parameters: One parameter is required for this method.
value: value whose presence in this map is to be tested.
Returns: true if this map maps one or more keys to the specified value.
Exceptions: NA
Approach
Java
import java.util.LinkedHashMap;public class LinkedHashMapcontainsValue {public static void main(String args[]) {LinkedHashMap<String, Integer> linkedHashMap =new LinkedHashMap<String, Integer>();linkedHashMap.put("Java", 1);linkedHashMap.put("Hello", 2);Object value = 1;System.out.println(linkedHashMap.containsValue(value));}}
Output:
true
No comments:
Post a Comment