Last Updated: 25 September, 2022
A multi-dimensional array that contains the different sizes of child arrays is known as a Jagged array in Java. A jagged array is similar to a multidimensional array in that it stores the data in the form of a table but it has different sizes of columns in a row.
Syntax of Jagged Array:
A pictorial representation of a Jagged array in Java.
Above shown is a two-dimensional Jagged array. In this array, the number of rows is 4, but the columns are different in size.
Let's see the examples of Jagged array in Java as given below:
Example 1: Jagged Array in Java
The given program defines a Jagged array of 3 rows. The column numbers of each row are different.
Output
As shown in the output, the first row of Jagged array has 3 columns, the second row has 4 columns, and the third row has 2 columns.
Let's see another example of Jagged Array given below.
Example 2: Jagged Array in Java
Output
That's all guys, hope this Java article is helpful for you.
Happy Learning... 😀
feedback@javabytechie.com