package com.Summer_0421.cn; /** * @author Summer * 二维数组遍历的方式for普通循环和foreach循环 */ public class Test03 { public static void main(String[] args) { show1(); show2(); } private static void show2() { int[][] its = new int[][]{{1},{1,2},{1,2,3},{1,2,3,4}}; for (int[] is : its) { for (int i : is) { System.out.print(i+" "); } System.out.println(); } } private static void show1() { int[][] its = new int[][]{{1},{1,2},{1,2,3},{1,2,3,4}}; for (int i = 0; i < its.length; i++) { for (int j = 0; j < its[i].length; j++) { System.out.print(its[i][j]+" "); } System.out.println(); } } }
原文地址:https://www.cnblogs.com/summerdata/p/10745833.html
时间: 2024-10-12 21:14:38