Select all the code that causes a compile error from this
A. int a[] = new int[2][3] B.int[] b = new int[2.3] C.int c[] = new int[23] D.int x = 2 , y=3; int[] d = new int[xy]; E.int[][] e = new int[2][]; F.int f[][] = new int[][3];
The answer is ABF.
A is A compile error occurs because you are trying to assign the 2D array on the right side to the 1D array on the left side.
B is Real numbers cannot be used to index an array. Therefore, a compile error will occur.
F is A compile error occurs because the number for the first dimension is not specified even though the element for the second dimension is specified.
This cannot be TypeScript as it is. Since the js array is actually made up of a java List structure, it is not possible to secure and declare the elements of a two-dimensional array.
If it is a one-dimensional array, it can be declared in the form of new Array (1) ;, but since it is not possible to create a two-dimensional array, var array:any = new Array(3); for (var i = 0; i < 3; i++) { array[i] = new Array(2); } Then you can create a 3x2 two-dimensional array.
Recommended Posts