11:09 pm - Saturday May 27, 2017

Check whether a value is present in hashtable boolean contains(Object value)

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 function returns  true if the key maps to the value argument in the hashtable.Otherwise it returns false .

Example Program

import java.util.Hashtable;

public class HashtableContains 
{

	public static void main(String[] args)

	{

		Hashtable<String, Object> myset = new Hashtable<String, Object>();

		myset.put("Summer", 1);

		myset.put("winter", 2);

		myset.put("autumn", 3);

		boolean exist = myset.contains("winter");

		System.out.println("Is the element 'winter' exist:" + exist);

	}

}

Output

           Is the element ‘winter’ exist:false

BACK

Filed in: Java Examples

Comments are closed.