出于某种原因,在 IntelliJ 中(如果这很重要),当我尝试初始化 2D 数组时,只有第一个框会根据我指定的大小进行初始化。 IE。int[][] grid = new int[9][9];
当我运行调试器时,它显示我已经创建了一个数组int[9][]
。有谁知道我做错了什么?难道我需要更新一些东西吗?任何事情都有帮助。谢谢。
它只是一个调试器表示。
它总是工作得很好。
It do在内存中创建一个二维数组。
public static void main(String[] args) {
int[][] grid = new int[9][9];
System.out.println(grid.length);
System.out.println(grid[0].length);
}
此代码将始终正确返回尺寸,如下所示:
9
9
What you might get in a debugger is something like this - where definitely is not written int[9][9] what you are expected, however this is a representation only - there is nothing with correctness.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)