| 7 | public class RaggedArray { |
| 8 | static int val = 1; |
| 9 | public static void main(String[] args) { |
| 10 | SplittableRandom rand = new SplittableRandom(47); |
| 11 | // 3-D array with varied-length vectors: |
| 12 | int[][][] a = new int[rand.nextInt(7)][][]; |
| 13 | for(int i = 0; i < a.length; i++) { |
| 14 | a[i] = new int[rand.nextInt(5)][]; |
| 15 | for(int j = 0; j < a[i].length; j++) { |
| 16 | a[i][j] = new int[rand.nextInt(5)]; |
| 17 | Arrays.setAll(a[i][j], n -> val++); // [1] |
| 18 | } |
| 19 | } |
| 20 | System.out.println(Arrays.deepToString(a)); |
| 21 | } |
| 22 | } |
| 23 | /* Output: |
| 24 | [[[1], []], [[2, 3, 4, 5], [6]], [[7, 8, 9], [10, 11, |