0% found this document useful (0 votes)
6 views

Module 5 - 2D Arrays

two dimensional array

Uploaded by

Dhan Belgica
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Module 5 - 2D Arrays

two dimensional array

Uploaded by

Dhan Belgica
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

2D Arrays

Table of
Contents
1. 2D Arrays
2. Declaring 2D Arrays
3. Nested For Loop
4. Iterating 2D Arrays using For
Loops
It is arrays within an array. It
basically looks like a table with
rows and columns.
2D Arrays
It can only store one datatype at
a time like the 1D arrays.

2D Arrays
datatype identifiers [][] = {
{val1,val2},
{val1,val2},
};

Declaring 2D Arrays
datatype identifiers [][] = new
datatype[row][col];

Declaring 2D Arrays
Accessing 2D Arrays

Index 0 1 2
int numbers [][] = {
{ 9, 8 }, 0 9 8 null
{ 0 },
{ 1, 2 ,3 }, 1 0 null null
{}
}; 2 1 2 3

3 null null null


Read Values:
System.out.print(identifier[row]
[col]);

Accessing 2D Arrays
Write Values:
identifier[row][col] = value;

Accessing 2D Arrays

You might also like