3:33 pm - Sunday August 20, 2017

Hash table example program using the boolean value is available using boolean() method.

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

BACK

This program Hash Table used boolean value is availbale using boolean() method.

Example Program


import java.util.Hashtable;

public class HashTableboolean {

	public static void main(String[] args) {

		// create two has table

		Hashtable htable = new Hashtable();

		// put value into table

		htable.put(1, "Dog");

		htable.put(2, "Cat");

		htable.put(3, "Cow");

		htable.put(4, "Donkey");

		// check if table contain a value

		boolean isavailable = htable.containsValue("Cat");

		// display search list available

		System.out.println("Hash table contains a value 'Cat': " + isavailable);

	}
}

 

Output

Hash table contains a value ‘Cat': 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<K,V>

 

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

BACK

Filed in: Z-A All Java Codes

Comments are closed.