Multidimensional Arrays in Java

Multidimensional Arrays in Java

In the last lesson we learned about One-Dimensional Arrays in Java and how to use them. Now, we will see about a concept of arrays in Java i.e. Multidimensional Arrays. Multi-dimensional arrays as the name suggests are arrays of arrays. You need to use two square brackets to declare a multidimensional array, unlike one-dimensional array.

Let us see an example to declare a 2 by 3 multidimensional array,

The following figure displays how a multidimensional array forms a 2×3 matrix,

Multidimensional Arrays in Java

In the above, you can see the left index determines row and the right index determines column.

We will now see how to display each element from our 2×3 matrix,

The following is the output displaying each element,

Mutidimensional Arrays Example

In this lesson, we saw how to work with Multidimensional arrays in Java.

Arrays in Java
Vectors in Java
Studyopedia Editorial Staff
Studyopedia Editorial Staff
[email protected]

We work to create free tutorials for all.

No Comments

Post A Comment