Print Array 3X3 in the form of Matrix
public class Print_array_in_matrix
{
public static void main(String[] args)
{
String sRes="";
int aArray[][]=new int [3][3];
aArray[0][0]=0;
aArray[0][1]=0;
aArray[0][2]=0;
aArray[1][0]=0;
aArray[1][1]=0;
aArray[1][2]=0;
aArray[2][0]=0;
aArray[2][1]=0;
aArray[2][2]=0;
for (int i=0 ; i<=aArray.length-1 ;i++)
{
for (int j=0;j<=aArray[0].length-1;j++)
{
sRes=sRes+" "+aArray[i][j];
}
sRes=sRes+"\n";
}
System.out.print(sRes);
{
String sRes="";
int aArray[][]=new int [3][3];
aArray[0][0]=0;
aArray[0][1]=0;
aArray[0][2]=0;
aArray[1][0]=0;
aArray[1][1]=0;
aArray[1][2]=0;
aArray[2][0]=0;
aArray[2][1]=0;
aArray[2][2]=0;
for (int i=0 ; i<=aArray.length-1 ;i++)
{
for (int j=0;j<=aArray[0].length-1;j++)
{
sRes=sRes+" "+aArray[i][j];
}
sRes=sRes+"\n";
}
System.out.print(sRes);
}
}
No comments:
Post a Comment