本帖最后由 cloud1991 于 2015-10-3 15:48 编辑
- package com.itheima;
- public class Test11 {
- public static void main(String[] args){
- int[][]arrays = {{1,2,3},{4,5,6},{7,8,9}};
- int sum =0;
- for(int i=0;i<3;i++){
- for( int j=0;j<3;j++){
- if(i==j){
- sum+=arrays[i][j];
- }
-
- }
- }
- System.out.println(sum);
- }
- }
复制代码
|