Difference Between One-Dimensional (1D) and Two-Dimensional (2D) Array


In this post, we will understand the difference between one dimensional array and two dimensional array.

One dimensional array

  • It helps store a single list of elements that are similar data type.

  • The total bytes is calculates as the product of the datatype of variable array and the size of the array.

C++ declaration

type variable_name[ size ];

Java declaration

type variable_name [ ];
variable_name = new type[size];


int [ ] a = new int [10];

Two-Dimensional array

  • It helps store 'list of lists' or 'array of arrays' or 'array of one dimensional arrays', i.e nested arrays.

  • The total bytes is equivalent to product of datatype of variable array and size of first index and size of the second index.

C++ declaration

type variable_name[size1][size2];

Java declaration

type variable_name = new int[size1][size2];


type variable_name = new int[size1][size2];

Updated on: 24-Mar-2021

622 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements