遍历2维数组

来源:互联网 发布:蔡珍妮淘宝工作室地址 编辑:程序博客网 时间:2024/04/29 22:06

例:

public class Test {
 public static void main(String[] args) {
  int[][] a={{1,2,3},{4,5,6,7}};
  for(int i=0;i<a.length;i++){
   for(int j=0;j<a[i].length;j++){
    System.out.print(a[i][j]+" ");
    
   }
   
  }
 }

}

 

输出结果:1 2 3 4 5 6 7

原创粉丝点击