OnJava8-Examples/arrays/AssemblingMultidimensionalArrays.java
2020-10-07 13:35:40 -06:00

23 lines
662 B
Java

// arrays/AssemblingMultidimensionalArrays.java
// (c)2020 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://OnJava8.com for more book information.
// Creating multidimensional arrays
import java.util.*;
public class AssemblingMultidimensionalArrays {
public static void main(String[] args) {
Integer[][] a;
a = new Integer[3][];
for(int i = 0; i < a.length; i++) {
a[i] = new Integer[3];
for(int j = 0; j < a[i].length; j++)
a[i][j] = i * j; // Autoboxing
}
System.out.println(Arrays.deepToString(a));
}
}
/* Output:
[[0, 0, 0], [0, 1, 2], [0, 2, 4]]
*/