多维数组(二维数组)

 1 package com.pingfan.array;
 2 
 3 public class ArrayDemo5 {
 4     public static void main(String[] args) {
 5         //[4][2]面向对象
 6         /*
 7             1,2    array[0]
 8             2,3    array[1]
 9             3,4    array[2]
10             4,5    array[3]
11          */
12         int[][] array = {{1,2},{2,3},{3,4},{4,5}};
13         for (int i = 0; i < array.length; i++) {
14             for (int j = 0; j < array[i].length; j++) {
15                 System.out.println(array[i][j]);
16             } 
17         }
18     }
19     //打印数组元素
20     public static void printArray(int[] arrays){
21         for (int i = 0; i < arrays.length; i++) {
22             System.out.println(arrays[i] + " ");
23         }
24     }
25 }

 

posted @ 2021-04-30 10:53  HeartlessHero  阅读(56)  评论(0)    收藏  举报