KnowledgeBoat Logo
|

Computer Applications

Differentiate between one-dimensional and two-dimensional arrays.

Java Arrays

3 Likes

Answer

One-dimensional arrayTwo-dimensional array
One-dimensional array stores data in a single row or column.Two-dimensional array stores data in a grid or table, with rows and columns.
It uses one index to access array elements.It uses two indices to access array elements.
For example,
int arr[] = new int[10];
It creates a one dimensional array arr which stores 10 elements of int type.
For example,
int arr[][] = new int [3][3];
It creates a two dimensional array which has three rows and three columns to store 3 x 3 = 9 elements of int type.

Answered By

3 Likes


Related Questions