2014-01-13 40 views

回答

3

是的,你只需要嵌套for-loop。首先遍历testarray中的数组,然后在inner-for中遍历int元素。

int testarray[][] = {{3, 4}, {5,6}}; 
for (int[] arr : testarray) { 
    for (int i : arr) { 
     System.out.println(i); 
    } 
} 
1

这是acheive你想要的东西的一种方式......

int testarray[][] = {{1,2,4},{3, 4, 5}}; 
for(int j=0; j < testarray.length; j++) 
{ 
    for (int i : testarray[j]) { 
     System.out.println(i); 
    } 
} 

这是做它的另一种方式。

​​