不规则二维数组
时间:2021-07-01 10:21:17
帮助过:12人阅读
<无详细内容>
- package com.sjzmlb.test;
- /**
- *
- * @author sjzmlb
- *
- */
- public class TestArray {
- public static void main(String[] args) {
- // -----不规则二维数组 ----
- int[][] ints = new int[5][];
- for (int i = 0; i < 5; i++) {
- ints[i] = new int[i + 1];
- for (int j = 0; j < i + 1; j++) {
- ints[i][j] = i + 1;
- }
- }
- for (int[] i : ints) {
- for (int j : i) {
- System.out.print(j);
- }
- System.out.println();
- }
- }
- }
- 1
- 22
- 333
- 4444
- 55555
|