首页 > 编程语言 > 详细

JAVA遍历二位数组的方法

时间:2015-02-07 18:53:52      阅读:219      评论:0      收藏:0      [点我收藏+]
//使用方法对于二维数组进行遍历
package com;


import java.util.Arrays;


public class CompoundInterest {


public static void main(String[] args) {
// TODO Auto-generated method stub
double[][] balances= new double[3][3];

for(int j = 0; j < balances[0].length; j++){
balances[0][j] = 1000;
}
for(int j = 0; j < balances[1].length; j++){
balances[1][j] = 2000;
}
for(int j = 0; j < balances[0].length; j++){
balances[2][j] = 3000;
}
System.out.println("循环遍历二维数组");
//遍历方法1
for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){
System.out.print(balances[i][j]  + "   ");
if(j == 2){
System.out.println();
}
}
}

System.out.println("方法遍历二维数组");
//遍历方法2
System.out.println(Arrays.deepToString(balances));

}


}

JAVA遍历二位数组的方法

原文:http://blog.csdn.net/u012965373/article/details/43605269

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