[go: up one dir, main page]

0% found this document useful (0 votes)
32 views1 page

Two Dimensinal Array Access

This document shows how to enter values into a 2D array in Java and then display those values. It creates a 2D integer array with 2 rows and 3 columns, uses nested for loops to populate the array with incrementing numbers from user input, and then uses another nested for loop to print out each element of the 2D array.

Uploaded by

aasxdas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views1 page

Two Dimensinal Array Access

This document shows how to enter values into a 2D array in Java and then display those values. It creates a 2D integer array with 2 rows and 3 columns, uses nested for loops to populate the array with incrementing numbers from user input, and then uses another nested for loop to print out each element of the 2D array.

Uploaded by

aasxdas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

TO enter and display values in two

dimensional array
public class ClassDemo {
public static void main(String
args[]) {
int[][] array = new int[2][3];
Scanner sc= new Scanner(System.in);
// scan the array
System.out.println("plx enter 5 values");
int a=0;
for ( int i=0; i< 2; i++ )
{
for ( int j=0; j<3;j++ )
{
array[ i ][j] = a;
a++;
}
}
for ( int i=0; i< 2; i++ )
{
for ( int j=0; j<3;j++ )
System.out.println("array["+ i+ "]
["+j+"]="+array[i][j]);
}
}
}

You might also like