
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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];
Advertisements