1. 程式人生 > >二維陣列遍歷

二維陣列遍歷

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

在這裡插入圖片描述