Commit eff0c28
committed
feat: Demonstrate 2D array declaration, iteration, and various declaration syntaxes
🧠 Logic:
- Initializes a 3×3 array `B` with literal values and prints its elements using nested loops indexing rows and columns (`B.length` and `B[0].length`).
- Shows multiple ways to declare and initialize 2D arrays (`int[][] A`, `int[][] c`, `int[][] D`, `int[] E[]`, and combined declarations).
- Highlights declaration pitfalls with mixed dimensions in a single statement (e.g., `int[] M, F[]` vs. `int[] I, J, K, L`).
- Includes comments explaining how `B[0].length` provides the column count for iteration.
Signed-off-by: Somesh diwan <[email protected]>1 parent 8a66912 commit eff0c28
1 file changed
+17
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
5 | | - | |
6 | | - | |
| 4 | + | |
| 5 | + | |
7 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
8 | 18 | | |
9 | 19 | | |
10 | 20 | | |
| |||
14 | 24 | | |
15 | 25 | | |
16 | 26 | | |
17 | | - | |
18 | 27 | | |
19 | 28 | | |
20 | | - | |
21 | | - | |
| 29 | + | |
22 | 30 | | |
23 | 31 | | |
24 | 32 | | |
25 | 33 | | |
26 | | - | |
| 34 | + | |
27 | 35 | | |
28 | 36 | | |
29 | 37 | | |
| |||
37 | 45 | | |
38 | 46 | | |
39 | 47 | | |
40 | | - | |
| 48 | + | |
41 | 49 | | |
42 | | - | |
| 50 | + | |
0 commit comments