Two Dimensional Array Program

This is very simple program of Java. In this lesson we will learn how to display arrange form of two dimensional array program.

Ads

Tutorials
Ads

Two Dimensional Array Program

This is very simple program of Java. In this lesson we will learn how to display arrange form of two dimensional array program. Firstly, we have to define class "TwoDimensional ". We are going to make a integer for array declaration Two dimensional array program. We are going to using for loop for performing the five rows and five columns.

Now applying the for loop and define an integer ' i' and it should be either less then" 5" or "j" in another for loop. Here in the second loop "j" the number of times to print. So the output will be display on the command prompt by using the println() method.

Here is the code of this program

 ``` class  TwoDimensionalArray {   public static void main(String[] args)    {   int TwoDarray[][]=new int[0][0];   int k=0;   for (int i=0; i<5; i++)   {   for(int j=0; j<=i; j++)   {   System.out.print(" "+ k);   k++;   }   System.out.println(" ");   }   } }```

`Download this Example`

Advertisements

Online Training Classes

Share on Google+

Two Dimensional Array Program

Posted on: June 25, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

Related Tutorials

Discuss: Two Dimensional Array Program   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):

Comments:5
devadas
June 25, 2011
java

i asking one program is develop a java program two dimensional array and display all its elements in matrix form using only one for loop please resolv this problem anyone ok
santhosh
September 12, 2011
c

two dimensional array example programme
GAURAV TRIVEDI
October 5, 2011
science

maximum value stored in two diamensional array .tell me answer plz
hotmama
February 17, 2012
this

this is full of crap.
Rohit Gupta
November 2, 2012
c++ loop

plz loop all program sent my Email id. I do not concept clear this program so full deaclear program sen my id. plz

Ads

Ads