Properties boolean containsValue(Object value) method Example Program


Returns true if this hashtable maps one or more keys to this value.
Note that this method is identical in functionality to contains (which predates the Map interface).

Program

package com.candidjava;

import java.util.Hashtable;
import java.util.Properties;

/* 
 * @author : Mohan 
 * @description : The containsValue() method is used to test if some value maps into the specified value in this hashtable.
 */
public class PropertiesContainValue {
	public static void main(String[] args) {
		Properties properties = new Properties();
		Hashtable ht = new Hashtable(properties);
		ht.put("1", "hari");
		ht.put("2", "anand");
		ht.put("3", "vinoth");
		ht.put("4", "mohan");
		ht.put("5", "karthick");
		System.out.println(ht);
		boolean b = ht.containsValue("anand");
		System.out.println(b);
	}

}

Output

{5=karthick, 4=mohan, 3=vinoth, 2=anand, 1=hari}
true

Explanation

public boolean containsValue(Object value)
Returns true if this hashtable maps one or more keys to this value.
Note that this method is identical in functionality to contains (which predates the Map interface).

Specified by:
containsValue in interface Map
Parameters:
value - value whose presence in this hashtable is to be tested
Returns:
true if this map maps one or more keys to the specified value
Throws:
NullPointerException - if the value is null
Since:
1.2


Related Post

Comments


©candidjava.com