[英]Java valid declarations of a two-dimensional array
I was going through one App which is suggested for the OCJP exam. 我正在通过一个建议用于OCJP考试的应用程序。 I found one question about the two-dimensional array. 我发现了有关二维数组的一个问题。
Question: Valid declarations of a two-dimensional array. 问题:二维数组的有效声明。
Options: 选项:
int[][] array2D;
int[2][2] array2D;
int array2D[];
int[] array2D[];
int[][] array2D[];
My selection: int[][] array2D;
我的选择: int[][] array2D;
and int[] array2D[]
but when I submit my answer it tells me that int[] array2D[]
is wrong and correct is int[][] array2D[];
和int[] array2D[]
但是当我提交答案时,它告诉我int[] array2D[]
是错误的,正确的是int[][] array2D[];
I think the int[][] array2D[];
我认为int[][] array2D[];
is incorrect answer. 是不正确的答案。
int[] array2D[]
recommended in programming? 在编程中建议使用int[] array2D[]
吗? The answer to this seems to be both options 1 and 4. 答案似乎是选项1和4。
int[][] array2D
is a standard way to declare a 2-d int array. 是声明二维int数组的标准方法。
Although int[] array2D[];
虽然int[] array2D[];
it is not a good practice it will work and will be a valid declaration. 这不是一个好习惯,它将起作用并且将是有效的声明。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.