我该如何将 Java 数组置于另一个数组中?
示例
import java.util.Arrays; public class ArrayWithinAnArray{ public static void main(String args[]) { int[] myArray1 = {23, 56, 78, 91}; int[] myArray2 = {123, 156, 178, 191}; int[] myArray3 = {223, 256, 278, 291}; int[] myArray4 = {323, 356, 378, 391}; int [][] arrayOfArrays = {myArray1, myArray2, myArray3, myArray4}; System.out.println(Arrays.deepToString(arrayOfArrays)); } }
输出
[[23, 56, 78, 91], [123, 156, 178, 191], [223, 256, 278, 291], [323, 356, 378, 391]]
Advertisements