Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.IdentityHashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

public class Main {
    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);
        Object v2 = objMap.get(o2);
        System.out.println(v2);

        // create entry set from the map
        Set<Entry<Object, Object>> enset = objMap.entrySet();

        System.out.println("Set view of the map: " + enset);
    }
}