Here this example will use containsValue method of LinkedHashMap class to check if LinkedHashMap object contains a particular value using in Java.
Source Code
package com.beginner.examples;
import java.util.LinkedHashMap;
public class CheckValueOfLinkedHashMap {
public static void main(String[] args) {
//create LinkedHashMap.
LinkedHashMap linkedHashMap = new LinkedHashMap();
linkedHashMap.put("1","Alice");
linkedHashMap.put("2","Bob");
linkedHashMap.put("3","Jack");
/*
* To check whether a particular value exists in LinkedHashMap use containsValue(Object key) method of LinkedHashMap.
*/
boolean result = linkedHashMap.containsValue("Alice");
System.out.println("Alice exists in LinkedHashMap ? : " + result);
}
}
Output:
Alice exists in LinkedHashMap ? : true
References
Imported packages in Java documentation: