访问数组所有元素:
import java.util.Arrays;
public class Hello{
public static void main(String[] args){
int[][] ns = {
{ 1, 2, 3, 4},
{ 5, 6, 7, 8},
{ 9, 10, 11, 12}
};
int[] arr1 = ns[0]; //长度为4
System.out.println(Arrays.toString(arr1));
for(int[] arr : ns){
for(int n : arr){
System.out.print(n);
System.out.print(", ");
}
}
System.out.println();
System.out.println(Arrays.deepToString(ns));
}
}