In computer science, a jagged array, also known as a ragged array [1] or irregular array [2] is an array of arrays of which the member arrays can be of different lengths,[3] producing rows of jagged edges when visualized as output.
In contrast, two-dimensional arrays are always rectangular[4] so jagged arrays should not be confused with multidimensional arrays, but the former is often used to emulate the latter.
Arrays of arrays in languages such as Java, PHP, Python (multidimensional lists), Ruby, C#.NET, Visual Basic.NET, Perl, JavaScript, Objective-C, Swift, and Atlas Autocode are implemented as Iliffe vectors.
In C# and Java[5] jagged arrays can be created with the following code:[6] In C and C++, a jagged array can be created (on the stack) using the following code: In C/C++, jagged arrays can also be created (on the heap) with an array of pointers: In C++/CLI, jagged array can be created with the code:[7] In Fortran, a jagged array can be created using derived types with allocatable component(s): In Python, jagged arrays are not native but one can use list comprehensions to create a multi-dimensional list which supports any dimensional matrix:[8]