Home > Backend Development > C++ > What is the difference between multidimensional array and jagged array?

What is the difference between multidimensional array and jagged array?

WBOY
Release: 2023-09-10 12:13:02
forward
1260 people have browsed it

What is the difference between multidimensional array and jagged array?

Multidimensional array

Multidimensional array is also called a rectangular array. You can define a 3-dimensional array of integers as -

int [ , , ] val;
Copy after login

Let's see how to define a 2-dimensional array.

int[,] val = new[3,3]
Copy after login

Jagged array

Jagged array is an array of arrays. To access an element from it, just mention the index of that particular array.

Here, we have a jagged array of 5 integer arrays -

int[][] a = new int[][]{new int[]{0,0},new int[]{1,2}, new int[]{2,4},new int[]{ 3, 6 }};
Copy after login

The above is the detailed content of What is the difference between multidimensional array and jagged array?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template