TwoDimArray.java


/*TwoDimArray.java
This applet will fill and dump a two dimentional arrays
< applet
code=TwoDimArray
width=325
height=200 >
< /applet >
*/

import java.applet.*;
import java.awt.*;

public class TwoDimArray extends Applet
{
	Button Go=new Button("See Matrix");
	TextArea Result=new TextArea(8,50);

	public void init()
	{
		add(Go);
		add(Result);
	}

	public boolean action(Event e, Object o)
	{
		
		//Declare two dimenstional array
		int x[][]=new int[10][10];
		
		//fill two dimentional array
		for(int i=0;i<=3;i++)
			for(int k=0;k<=4;k++)
				x[i][k]= i + k;
		
		//dump two dimentional array
		for(int n=0;n<=3;n++)
		{
			for (int j=0; j<=4; j++)
			Result.appendText("x["+n+"]["+j+"] = "+x[n][j]+"     ");
		
			Result.appendText("\n");
		}
			return true;
	}
}

Output for TwoDimArray.java