I am having a little bit of struggle with Java maps. I want to have a map which takes a byte[] as a key and returns a custom object as the value.
First I tried using hash maps, but because I used to different arrays, but with the same values, it didn't work. Also using Arrays.hashCode() isn't possible because multible arrays with different values, would have the same hash.
Now I'm trying it with a TreeMap instead of a HashMap, but now I don't know how to solve the
Exception in thread "main" java.lang.ClassCastException: [B cannot be cast to java.lang.Comparable
at java.util.TreeMap.compare(TreeMap.java:1294)
at java.util.TreeMap.put(TreeMap.java:538)
Exception which gets thrown when I try to add an Object.
Has somebody an idea how I could solve this exception? Or more specific, how and which Comparator should I provide to the TreeMap?