A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 刘为华 中级黑马   /  2015-11-8 19:05  /  261 人查看  /  3 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

二维数组如何遍历????????

3 个回复

正序浏览
等你学到后面就会知道,遍历越来越简单,就比如说for循环,针对集合的迭代器,还有增强for!!
   这些你都没学到吗?
回复 使用道具 举报
这是随便一个
回复 使用道具 举报
class ShuZu {
        public static void main(String[] args) {
                int arr[][] = {{1,2,3},{4,5},{6,7,8,9}};
                bianLi(arr);
        }
        public static void bianLi (int arr[][]) {
                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();
                }
        }
}
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马