【发布时间】:2020-11-30 16:32:27
【问题描述】:
我想将一个数组映射到ArrayList,这样如果两个数组相同,它们就会映射到同一个东西。
这会输出null:
HashMap<int[], Integer> map = new HashMap<>();
map.put(new int[1], 0);
System.out.println(map.get(new int[1]));
我希望输出为0。是否有捷径可寻?我应该使用TreeMap 吗?如何在TreeMap 中执行此操作?
【问题讨论】:
标签: java arrays hashmap implementation treemap