Multidimensional array

In associative array, we can store one value with only one key.
But if we want to store one or more keys for one value.
This can be done using multi-dimensional arrays.
A multi-dimensional array can be two-dimensional or three-dimensional array depending on indices.

A two-dimensional array is known as array of arrays.
A three-dimensional array is known as array of arrays of arrays.

 

Using multi-dimensional array you can store data in table form.
Let’s see following example:

Subject Marks Grade
Mathematics 23 D
Science 45 C
English 65 B
Drawing 80 A

Now this above table can be stored using multi-dimensional array as.

Output:

You can print this table using for loop.

Output:

Ankit Wasankar

Senior Java Developer
Java 11 | Microservices | Reactjs | SQL

Help others by sharing the content!

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.