Check an Value Is Exists in Java TreeMap Example

Check an Value Is Exists in Java TreeMap Example


Posted in : Java Posted on : December 3, 2010 at 5:30 PM Comments : [ 0 ]

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

Download The Code

Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics