In my program, I wanted to use a HashMap of Integer[]s, but I was having trouble retrieving the data. After further investigation, I found that this, without anything else in the program, prints null
.
HashMap<Integer[], Integer> a = new HashMap<Integer[], Integer>();
Integer[] b = {5, 7};
Integer[] c = {5, 7};
a.put(b, 2);
System.out.println(why.get(c));
I don't want to have to iterate through the HashMap with a.keySet()
if I don't have to. Is there any other way to achieve the desired result?