This Java Example shows how to know that an value is exists in the specified TreeMap object in java.
Check an Value Is Exists in Java TreeMap Example
This Java Example shows how to know that an value is exists in the specified
TreeMap object in java. To get the value from TreeMap object we use boolean
containsValue(value) method. This method returns true if Map contains the
specified value
otherwise returns false.
Example: ContainsValueInTreeMap.java
package devmanuals.com; import java.util.*; public class ContainsValueInTreeMap { public static void main(String args[]) { TreeMap Tmap = new TreeMap(); Tmap.put("Gyan", "Singh"); Tmap.put("Ankit", "Kumar"); Tmap.put("Arunesh", "Kumar"); Tmap.put("Anand", "Nagar"); Tmap.put("Ram", "Prakash"); boolean bool = Tmap.containsValue("Kumar"); System.out.println("Is Kumar is exists in map : " + bool); } }
Output:
Is Kumar is exists in map : true |
[ 0 ] Comments