动态二维数组赋值及for循环遍历和toString遍历

package com.Summer_0421.cn;

import java.util.Arrays;

/**
 * @author Summer
 * 动态二维数组赋值及for循环遍历和toString遍历
 */
public class Tesrt04 {

    public static void main(String[] args) {
        int[][] arr = new int[2][2];
        arr[0][0] = 100; 
        arr[0][1] = 1; 
        arr[1][0] = 10; 
        arr[1][1] = 1000; 
        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();
        }
        for (int[] is : arr) {
            for (int i : is) {
                System.out.print(i+" ");
            }
            System.out.println();
        }
        for (int i = 0; i < arr.length; i++) {
            System.out.println(Arrays.toString(arr[i]));
        }
    }
}

 

posted @ 2019-04-21 17:26  Geek张东坡  阅读(1076)  评论(0编辑  收藏  举报