首页 > 编程语言 > 详细

二维数组

时间:2020-05-10 20:24:47      阅读:36      评论:0      收藏:0      [点我收藏+]

一. 二维数组遍历

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!