Example usage for java.util IdentityHashMap get

List of usage examples for java.util IdentityHashMap get

Introduction

In this page you can find the example usage for java.util IdentityHashMap get.

Prototype

@SuppressWarnings("unchecked")
public V get(Object key) 

Source Link

Document

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    IdentityHashMap<Object, Object> objMap = new IdentityHashMap<Object, Object>();

    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
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    IdentityHashMap<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
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    IdentityHashMap<Object, Object> objMap = new IdentityHashMap<Object, Object>();

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

    Object v1 = objMap.get(o1);
    System.out.println(v1);/*from www  .j a v a 2 s .c  o  m*/
    Object v2 = objMap.get(o2);
    System.out.println(v2);

    System.out.println(objMap.hashCode());
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    IdentityHashMap<Object, Object> objMap = new IdentityHashMap<Object, Object>();

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

    Object v1 = objMap.get(o1);
    System.out.println(v1);/*from  w  ww. jav  a  2 s  .c  o m*/
    Object v2 = objMap.get(o2);
    System.out.println(v2);

    System.out.println(objMap);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    IdentityHashMap<Object, Object> objMap = new IdentityHashMap<Object, Object>();

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

    Object v1 = objMap.get(o1);
    System.out.println(v1);// w w w  . ja va  2 s.c o m
    Object v2 = objMap.get(o2);
    System.out.println(v2);

    System.out.println(objMap.isEmpty());
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    IdentityHashMap<Object, Object> objMap = new IdentityHashMap<Object, Object>();

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

    Object v1 = objMap.get(o1);
    System.out.println(v1);//w  ww  .j  a v  a 2 s  . com
    Object v2 = objMap.get(o2);
    System.out.println(v2);

    System.out.println("Value at key '2' is: " + objMap.get(o1));
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    IdentityHashMap<Object, Object> objMap = new IdentityHashMap<Object, Object>();

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

    Object v1 = objMap.get(o1);
    System.out.println(v1);//  ww w.jav  a2  s.  c  o  m
    Object v2 = objMap.get(o2);
    System.out.println(v2);

    boolean isavailable = objMap.containsValue("first");

    System.out.println(isavailable);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    IdentityHashMap<Object, Object> objMap = new IdentityHashMap<Object, Object>();

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

    Object v1 = objMap.get(o1);
    System.out.println(v1);//  w w  w .  java  2s.  c om
    Object v2 = objMap.get(o2);
    System.out.println(v2);

    Map<Object, Object> objMap1 = new IdentityHashMap<Object, Object>();

    System.out.println(objMap1.equals(objMap));
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    IdentityHashMap<Object, Object> objMap = new IdentityHashMap<Object, Object>();

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

    Object v1 = objMap.get(o1);
    System.out.println(v1);//w  w w  . ja  v a 2  s .c  om
    Object v2 = objMap.get(o2);
    System.out.println(v2);

    // check if key 3 exists
    boolean isavailable = objMap.containsKey(o1);

    System.out.println(isavailable);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    IdentityHashMap<Object, Object> objMap = new IdentityHashMap<Object, Object>();

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

    Object v1 = objMap.get(o1);
    System.out.println(v1);/* w  w w.j  av a  2 s . c  o m*/
    Object v2 = objMap.get(o2);
    System.out.println(v2);

    objMap.clear();

    System.out.println("Map content after clear: " + objMap);

}