二维数组遍历

package javacore;

/**
 * @author lixw
 * @date created in 12:16 2018/12/17
 */
public class TwoDimensionalArrayTest {
    public static void main(String[] args) {
        int[][] arr = {
                {216, 1, 2, 3, 5},
                {1, 6, 5, 3, 8},
                {5, 6, 8, 3, 9}
        };

        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();
        }
    }
}

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_42664961/article/details/85048104