Jagged Array in Java
Jagged Array is about Java arrays. An array is a fixed-size row of the same type. Index from 0. Length is a.length (a field, not a method). Last valid index is length - 1.
Create Jagged Array: int[] a = new int[5]; or int[] a = {10, 20, 30};. A 2D array is an array of arrays: int[][] m = {{1,2},{3,4}}; m[1][0] is 3. Jagged means rows can have different lengths.
Jagged Array size cannot grow. If you need grow/shrink, use ArrayList. Out of range → ArrayIndexOutOfBoundsException.
Let's take this on the board with one tiny Main class — no extra files. Jagged Array in Java — prints length 3, middle value 20, then all values. Start from main, go line by line, and stop at each print. That output is the proof for Jagged Array.
index → 0 1 2
array → [10, 20, 30]
↑ ↑
first length-1Contrast array vs ArrayList in one line.