8:12 am - Tuesday November 21, 2017

Check whether a key is avilable in Hashtable boolean containsKey(Objectkey)

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 method returns true if the specified object is a key in the hashtable, otherwise returns false .

Example Program

import java.util.Hashtable;

public class HashtableContainsKey 

{

	public static void main(String args[])
       
	{

         
        Hashtable htable = new Hashtable();

        htable.put(1, "add");

        htable.put(2, "sub");

        htable.put(3, "Mul");

        htable.put(4, "Div")

        boolean isavailable=htable.containsKey(3)

        System.out.println("Hash table contains key '3': "+isavailable)

     }
}

Output

         Hash table contains key ‘3’: true

BACK

Filed in: Java Examples

Comments are closed.