Properties boolean contains(Object value) method Example Program


Tests if some key maps into the specified value in this hashtable. This operation is more expensive than the containsKey method.
Note that this method is identical in functionality to containsValue, (which is part of the Map interface in the collections framework).

Program

package com.candidjava;

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

/* 
 * @author : Mohan 
 * @description : The contains(Object value) method is used to test if some key maps into the specified value in this hashtable.
 */
public class PropertiesContain {

	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.contains("karthick");
		System.out.println(b);
	}

}

Output

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

Explanation

public boolean contains(Object value)
Tests if some key maps into the specified value in this hashtable. This operation is more expensive than the containsKey method.
Note that this method is identical in functionality to containsValue, (which is part of the Map interface in the collections framework).

Parameters:
value - a value to search for
Returns:
true if and only if some key maps to the value argument in this hashtable as determined by the equals method; false otherwise.
Throws:
NullPointerException - if the value is null


Related Post

Comments


©candidjava.com