Java IdentityHashMap.equals(Object o)
Syntax
IdentityHashMap.equals(Object o) has the following syntax.
public boolean equals(Object o)
Example
In the following code shows how to use IdentityHashMap.equals(Object o) method.
import java.util.IdentityHashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
/*w w w . j a va 2 s .co m*/
public class Main {
public static void main(String[] argv) throws Exception {
Map<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);
Object v2 = objMap.get(o2);
System.out.println(v2);
Map<Object, Object> objMap1 = new IdentityHashMap<Object, Object>();
System.out.println(objMap1.equals(objMap));
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »