final HashMap<Integer, HashMap<Integer, Integer[]>> teams;
teams= new HashMap<Integer, HashMap<Integer, Integer[]>>();
teams.put(1,new HashMap<Integer, Integer[]>(){{
put(2,new Integer[] { 1,0});}});
System.out.println(teams.get(1).get(2));
我正在尝试在java中实现哈希的哈希。我需要打印存储在散列的散列中的整数数组。任何这方面的帮助将不胜感激。
最佳答案
您的代码是正确的(我只是在此处重新缩进),并且我将调用添加到 Arrays.toString println 调用中的方法。
final HashMap<Integer, HashMap<Integer, Integer[]>> teams;
teams = new HashMap<Integer, HashMap<Integer, Integer[]>>();
teams.put(1, new HashMap<Integer, Integer[]>() {
{
put(2, new Integer[] { 1, 0 });
}
});
System.out.println(Arrays.toString(teams.get(1).get(2)));
关于java - 打印存储在散列的散列中的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20043024/