WeakHashMap boolean containsValue(Object value) method Example Program


Returns true if this map maps one or more keys to the specified value.

Program

package com.candidjava;

import java.util.Map;
import java.util.WeakHashMap;
/* 
 * @author : Mohan 
 * @description : The containsValue(Object value) method is used to return true if this map, maps one or more keys to the specified value.
 */
public class WeakHashMapContainsValue {
	public static void main(String[] args) {
		WeakHashMap weakHashMap = new WeakHashMap();

		weakHashMap.put("1", "anandh");
		weakHashMap.put("2", "hari");
		weakHashMap.put("3", "vinoth");
		weakHashMap.put("4", "kamal");
		weakHashMap.put("5", "karthic");
		System.out.println("Checking value kamal ="
				+ weakHashMap.containsValue("kamal"));
	}
}

Output

Checking value kamal =true

Explanation

public boolean containsValue(Object value)
Returns true if this map maps one or more keys to the specified value.
Specified by:
containsValue in interface Map
Overrides:
containsValue in class AbstractMap
Parameters:
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


Related Post

Comments


©candidjava.com