This Java Example shows how to know that an Value is exists in the specified LinkedHashMap object in java.
Check an Value Is Exists in Java LinkedHashMap Example
This Java Example shows how to know that an Value is exists in the specified
LinkedHashMap object in java. To get the Value from LinkedHashMap object we
use boolean containsValue(object value) method. This method returns true if
list contains mapping for the specified Value otherwise returns false.
Example: ContainsValueInLinkedHashMap.java
package devmanuals.com; import java.util.*; public class ContainsValueInLinkedHashMap { public static void main(String args[]) { LinkedHashMap Lhm = new LinkedHashMap(); Lhm.put(1, "Gyan"); Lhm.put(6, "Ankit"); Lhm.put(5, "Arun"); Lhm.put(4, "Anand"); Lhm.put(3, "Ram"); boolean bool = Lhm.containsValue("Arun"); System.out.println("The Entries of LinkedHashMap are : " + Lhm); System.out.println("Is Value Arun is exists in map : " + bool); } }
Output:
The Entries of LinkedHashMap are :
{1=Gyan, 6=Ankit, 5=Arun, 4=Anand, 3=Ram} Is Value Arun is exists in map : true |
[ 0 ] Comments