Your question already says the correct answer ^^ but for completeness.

A Jagged or also called Ragged array is a n-dimensional array that need not the be reactangular means:

int[][] array = {{3, 4, 5}, {77, 50}};

For more examples you could look here and here!

Answer from Gerret on Stack Overflow
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ jagged-array-in-java
Jagged Array in Java - GeeksforGeeks
November 13, 2025 - Explanation: In the above example, we are creating a jagged array where each row will get one more element than the previous one, suppose the first row has one element then the second row has two element and then the third row has three element and so on. It fills the array with numbers starting from 0 and then prints them ... import java.util.Scanner; public class Geeks { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.print("Enter the number of sub-arrays: "); int numberOfArrays = scan.nextInt(); // Declare the jagged array int[][] jaggedArray = new
๐ŸŒ
DZone
dzone.com โ€บ data engineering โ€บ data โ€บ what is a jagged array in java with examples?
What Is a Jagged Array in Java With Examples? - DZone
January 22, 2024 - We use nested loops to iterate over the jagged array and calculate the sum of each row. The outer loop iterates over the rows, and the inner loop iterates over the columns of each row. The sum of each row is calculated by adding up all the elements in that row. ... public class JaggedArrayExample { public static void main(String[] args) { int[][] jaggedArray = { { 1, 2, 3 }, // First row with three elements { 4, 5 }, // Second row with two elements { 6, 7, 8, 9 }, // Third row with four elements { 10 } // Fourth row with one element }; // Calculate the sum of each row and display the results for (int i = 0; i < jaggedArray.length; i++) { int rowSum = 0; for (int j = 0; j < jaggedArray[i].length; j++) { rowSum += jaggedArray[i][j]; } System.out.println("Sum of row " + (i + 1) + ": " + rowSum); } } }
People also ask

What are jagged arrays in Java used for?
Jagged arrays in Java are perfect for storing irregular data where each group has a variable number of elements. Common uses include student records with different course loads, game boards with irregular layouts, survey responses with varying question sets, and hierarchical data structures.
๐ŸŒ
upgrad.com
upgrad.com โ€บ home โ€บ tutorials โ€บ software & tech โ€บ jagged array in java
What Is a Jagged Array in Java? Complete Implementation Guide
Is it possible to sort a jagged array in Java?
Yes, you can sort a jagged array using Java's Comparator interface to define custom sorting rules. Common approaches include sorting by row length (Arrays.sort(jaggedArray, Comparator.comparingInt(row -&gt; row.length))), by the first element in each row, or by calculated values like row averages or sums.
๐ŸŒ
upgrad.com
upgrad.com โ€บ home โ€บ tutorials โ€บ software & tech โ€บ jagged array in java
What Is a Jagged Array in Java? Complete Implementation Guide
Can a 3D jagged array be created in Java?
Yes, 3D jagged arrays are possible in Java where each second-level array contains third-level arrays of different lengths. They're useful for complex structures like building layouts (buildings โ†’ floors โ†’ rooms) or organizational hierarchies. Creation requires careful initialization of each nested array level.
๐ŸŒ
upgrad.com
upgrad.com โ€บ home โ€บ tutorials โ€บ software & tech โ€บ jagged array in java
What Is a Jagged Array in Java? Complete Implementation Guide
๐ŸŒ
Baeldung
baeldung.com โ€บ home โ€บ java โ€บ java array โ€บ jagged arrays in java
Jagged Arrays in Java | Baeldung
July 30, 2025 - In Java, a jagged array is a type of multidimensional array where each row can contain a different number of elements.
๐ŸŒ
Software Testing Help
softwaretestinghelp.com โ€บ home โ€บ java โ€บ jagged array in java โ€“ tutorial with examples
Jagged Array In Java - Tutorial With Examples
April 1, 2025 - In this tutorial, we discussed Jagged arrays which are Multidimensional arrays with varied sizes of columns in each row. These arrays are useful for improving the performance of the system.
๐ŸŒ
CodeGym
codegym.cc โ€บ java blog โ€บ random โ€บ jagged array in java
Jagged Array in Java
April 9, 2025 - Okay, real talk: a jagged array in Java is an array where every slot holds another array, and those inner arrays don't have to match sizes. It's like a regular 2D array's wild cousin none of that "every row's gotta be the same" nonsense
Find elsewhere
๐ŸŒ
Medium
medium.com โ€บ @hasibulhimu49 โ€บ understanding-jagged-arrays-in-java-for-viva-exams-725207e8301a
Understanding Jagged Arrays in Java (For Viva Exams) | by Mohammad Hasibul Hasan | Medium
February 8, 2025 - Answer: A jagged array is an array of arrays where each row can have a different number of columns. This is different from a 2D array where all rows have the same number of columns.
๐ŸŒ
Unstop
unstop.com โ€บ home โ€บ blog โ€บ jagged array in java | create, initialize & more (+examples)
Jagged Array In Java | Create, Initialize & More (+Examples)
December 30, 2024 - A jagged array in Java is an array of arrays with varying row sizes, making it non-rectangular. Each row can have a different number of elements.
๐ŸŒ
Upgrad
upgrad.com โ€บ home โ€บ tutorials โ€บ software & tech โ€บ jagged array in java
What Is a Jagged Array in Java? Complete Implementation Guide
June 9, 2026 - A jagged array in Java Programming (also known as a ragged array) is a multidimensional array where each row can have a different length.
๐ŸŒ
Codespindle
codespindle.com โ€บ Java โ€บ Java_Jagged_Arrays.html
Jagged Arrays in Java
A jagged array in Java is an array of arrays, where each element of the array can be a different size.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ jagged-array-in-java
Jagged Array in Java
June 23, 2020 - Jagged array is a multidimensional array where member arrays are of different size. For example, we can create a 2D array where first array is of 3 elements, and is of 4 elements. Following is the example demonstrating the concept of jagged array.
๐ŸŒ
Javatpoint
javatpoint.com โ€บ jagged-array-in-java
Jagged Array in Java - Javatpoint
Java Program to calculate the Difference between the Sum of the Odd Level and the Even Level Nodes of a Binary Tree
๐ŸŒ
Coddy.Tech
coddy.tech โ€บ learn โ€บ java โ€บ jagged arrays
Jagged Arrays โ€“ Java | Coddy
March 8, 2026 - Notice that when you first declare the array, you only specify the number of rows. Then, you initialize each row separately, specifying the number of columns for that row. ... Create a method named createJaggedArray that takes an integer n as input returns a jagged array of integers.
๐ŸŒ
Techie Delight
techiedelight.com โ€บ home โ€บ java โ€บ jagged array (ragged array) in java
Jagged array (Ragged array) in Java | Techie Delight
July 7, 2026 - The elements of a jagged array can be of different dimensions and sizes, unlike C-styled arrays that are always rectangular. We know that a two-dimensional array is nothing but an array of single-dimensional arrays. Therefore, it is possible to create a two-dimensional array in Java, where individual one-dimensional arrays have different lengths.
๐ŸŒ
Tutorjoes
tutorjoes.in โ€บ java_programming_tutorial โ€บ jagged_Array_in_java
Jagged-Array in Java
public class jagged_Array { public static void main(String args[]) { //Jagged Array using For Loop in Java Programming int a[][] = { {10, 20, 30, 40},//4 {10, 20, 30},//3 {10, 20, 30, 50}//4 }; for (int i = 0; i < a.length; i++) { for (int j = 0; j < a[i].length; j++) { System.out.print(" "+a[i][j]); } System.out.println(""); } } }
๐ŸŒ
Wikipedia
en.wikipedia.org โ€บ wiki โ€บ Jagged_array
Jagged array - Wikipedia
March 5, 2026 - Jagged array can be implemented with Iliffe vector data structure in languages such as Java, PHP, Python (multidimensional lists), Ruby, C#.NET, Visual Basic.NET, Perl, JavaScript, Objective-C, Swift, and Atlas Autocode.