IdentityHashMap containsKey Example

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


IdentityHashMap class containsKey example.

Here is the code

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

public class ContainsKey {

    public static void main(String args[]) {
        IdentityHashMap map = new IdentityHashMap();

        //Add the mapping into the map 
        map.put(1"A");
        map.put(2"A");
        map.put(3"B");

        System.out.println("Map " + map);
        //Tests whether the specified object reference 
        //is a key in this identity hash map. 
        System.out.println(map.containsKey(1));
    }
}

Output
Map {2=A, 1=A, 3=B}
true

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

HOME | COPYRIGHT | CONTACT US