Hashtable containsKey Example

Hashtable class containsKey method example. This example shows you how to use containsKey method.


Hashtable class containsKey method example.Tests if the specified object is a key in this hashtable.
syntax -public boolean containsKey(Object key)

Her is the code

/**
 * @ # ContainsKey.java
 * A class repersenting use to containsKey method 
 * of HashMap class in java.util package
 * version 19 May 2008
 * author Rose India 
 */
import java.util.*;

public class ContainsKey {

    public static void main(String[] arsg) {
        
        Hashtable table = new Hashtable();
        table.put(1"A");
        table.put(2"B");
        table.put(3"C");
        table.put(4"D");

        System.out.println("table :" + table);
        
        System.out.println("Table containkey 1 : " + table.containsKey(1));
    }
}

Output
 table :{4=D, 3=C, 2=B, 1=A}
Table containkey 1 : true

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US