Declaration of multidimensional array Let's try TypeScript for Java problem 4-4

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

Declaration of multidimensional array Let's try TypeScript for Java problem 4-4
Initialization of for Try to make Java problem TypeScript 5-4
Interface Try to make Java problem TypeScript 7-3
[Java beginner] About initialization of multidimensional array
Increment behavior Try to make Java problem TypeScript 3-4
String operation Try to make Java problem TypeScript 9-3
[Java] Summary of for statements
Utilization of Java array elements, for, length, value, and extended for statements
[For beginners] Summary of java constructor
[Java] Output multidimensional array / spreadsheet (AOJ⑥ spreadsheet)
Generics of Kotlin for Java developers
Dynamically increase the number of elements in a Java 2D array (multidimensional array)
Implementation of clone method for Java Record
[Java] Multidimensional array / inner product calculation (AOJ⑦ inner product)
Let's try WebSocket with Java and javascript!
Compare the elements of an array (Java)
List of download destinations for oracle java
Features of spring framework for java developers
[For beginners] Introduction to Java Basic knowledge of Java language ③ Array, selection structure, iteration structure