I've been testing out HashMap recently and I've stumbled upon an interesting problem. I have an array, a3, that I have set some arbitrary values. I then take this array and put it into a HashMap instance map.
My problem is that when I assign an Object instance the value of put("a3", a3), I can't seem to print out the address of the instance.
For example:
HashMap<Object, Object> map = new HashMap<Object, Object>();
int[] a3 = new int[] {1, 2, 3, 4};
map.put("a3", a3);
When I call System.out.println(map.put("a3", a3), I'm given an address in memory.
However, if I create an object instance and then try to print out that instance I get null.
Object copy = map.put("a3", a3);
System.out.println(copy);
Running the above segment gives me a value of null.
Any reason why both these statements, which appear identical, give me different results?