Java IdentityHashMap(int expectedMaxSize) Constructor

Syntax

IdentityHashMap(int expectedMaxSize) constructor from IdentityHashMap has the following syntax.

public IdentityHashMap(int expectedMaxSize)

Example

In the following code shows how to use IdentityHashMap.IdentityHashMap(int expectedMaxSize) constructor.


import java.util.IdentityHashMap;
import java.util.Map;
/* w w  w  . j  a  v a 2s.  c  o m*/
public class Main {
  public static void main(String[] argv) throws Exception {
    Map<Object, Object> objMap = new IdentityHashMap<Object, Object>(5);

    Object o1 = new Integer(123);
    Object o2 = new Integer(123);
    objMap.put(o1, "first");
    objMap.put(o2, "second");

    Object v1 = objMap.get(o1); // first
    Object v2 = objMap.get(o2); // second
  }
}