Java 如何将二维数组直接添加到hashmap?

Java 如何将二维数组直接添加到hashmap?,java,arrays,generics,int,Java,Arrays,Generics,Int,与此相反: int[][] someArr = { { 88, 35 }, { 11, 98 } }; mapDE = new HashMap<String, int[][]>(); mapDE.put("someKey", someArr); int[]someArr={{88,35},{11,98}; mapDE=newhashmap(); mapDE.put(“someKey”,someArr); 我想这样做是为了保存行代码: mapDE = new HashMap<

与此相反:

int[][] someArr = { { 88, 35 }, { 11, 98 } };
mapDE = new HashMap<String, int[][]>();
mapDE.put("someKey", someArr);
int[]someArr={{88,35},{11,98};
mapDE=newhashmap();
mapDE.put(“someKey”,someArr);
我想这样做是为了保存行代码:

mapDE = new HashMap<String, int[][]>();
mapDE.put("someKey", { { 88, 35 }, { 11, 98 } });
mapDE=newhashmap();
mapDE.put(“someKey”,{88,35},{11,98});
有什么简单的方法可以做到这一点吗?

mapDE.put(“someKey”、{88,35}、{11,98})未编译,因为
{{88,35},{11,98}
无法确保类型
int[][]]

您可以通过以下方式尝试:

    Map<String, int[][]> mapDE = new HashMap<String, int[][]>();
    mapDE.put("someKey",new int[][] { { 88, 35 }, { 11, 98 } });
Map mapDE=newhashmap();
put(“someKey”,新int[][{{88,35},{11,98});
mapDE.put(“someKey”,{88,35},{11,98})未编译,因为
{{88,35},{11,98}
无法确保类型
int[][]]

您可以通过以下方式尝试:

    Map<String, int[][]> mapDE = new HashMap<String, int[][]>();
    mapDE.put("someKey",new int[][] { { 88, 35 }, { 11, 98 } });
Map mapDE=newhashmap();
put(“someKey”,新int[][{{88,35},{11,98});
使用以下方法:

mapDE.put("somekey", new int[][]{
  { 0, 0 },
  { 0, 0 } });
使用以下命令:

mapDE.put("somekey", new int[][]{
  { 0, 0 },
  { 0, 0 } });

您非常接近,请尝试以下操作:

mapDE.put("someKey", new int[][]{{88, 35}, {11, 98}});

您非常接近,请尝试以下操作:

mapDE.put("someKey", new int[][]{{88, 35}, {11, 98}});