Hashtable contains Example

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


Hashtable class contains method example.Tests if some key maps into the specified value in this hashtable. This operation is more expensive than the containsKey method
syntax - public boolean contains(Object value)

Here is the code

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

public class Contains {

    public static void main(String args[]) {
        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 contains A : "+table.contains("A"));
    }
}

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

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

HOME | COPYRIGHT | CONTACT US