package com.test; import java.util.*; import static java.util.Arrays.fill; public class Main { public static void main(String[] args) { final int MAX = 10; int [][] a = new int[MAX][MAX]; for(int i = 1; i <= 9; i ++){ for(int j = 1; j <= i; j ++){ // Scanner num = new Scanner(System.in); // int digit = num.nextInt(); a[i][j] = j; } } // for(int []i : a){//多维数组中foreach语句的用法 // for(int j : i){ // System.out.println(j); // } // } for(int i = 1; i <= 9; i ++){ for(int j = 1; j <= i; j ++){ System.out.print(a[i][j] + " "); } System.out.println(); } // System.out.println(Arrays.deepToString(a));//区别于遍历一维数组的ToString方法 } }
标签:遍历,java,int,MAX,util,static,数组,多维,import From: https://www.cnblogs.com/8023yyl/p/17099887.html