二维数组

一. 二维数组遍历

package test_1;

  public class test_7 {
    public static void main(String[] args) {
      int[][] arr = {{1,2,3},{5,6},{12,13,14}};

      for(int i=0; i< arr.length ; i++) {
        for(int j=0; j < arr[i].length ; j++){
          System.out.print(arr[i][j] +" ");
          }
        System.out.println("");
      }
  }

}

二. 二维数组求和

package test_1;

  public class test_8 {

    public static void main(String[] args) {
      int[][] arr = {{33,44,55},{77,55,33},{33,55,77},{99,88,77}};
      int sum =0;
      for(int i=0; i< arr.length ; i++) {
        for(int j=0; j < arr[i].length ; j++){
          sum =sum +arr[i][j];
          }
      }System.out.println(sum);
}

}

******************************人因为有理想、梦想而变得伟大,而真正伟大就是不断努力实现理想、梦想*****************************
原文地址:https://www.cnblogs.com/cloudLi/p/12864702.html