We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Code: http://pastebin.com/XanGgM26
I tried to fill a hashmap with arrays but can't seem to retrieve a single array (the line in comment): I get a nullpointer exception. But retrieving all the values or keys seems to work fine. I think this line is the problem because an array isn't a primitive datatype: boolean[] result = elementMap.get(test); How can I solve this problem? Thanks.
Answers
Instead of making us click a link, can you post an MCVE here that demonstrates the problem?
Also, I don't think this will work the way you want it to. Here's my own little MCVE:
Run that code and notice that it prints false.
This is because arrays do not override the equals() method to check for anything in the array. The only time two arrays are equal is when they're the same reference:
The problem is: HashMaps rely on the equals() method. Therefore, it doesn't make a ton of sense to use arrays as keys in a map, unless you're keeping around the references for some reason.