source file name:  displayarray.java

class disparray

{

public static void main(String as[])

{

int A[][]=new int[3][3];

System.out.println("3 * 3 matrix values are generated by random()");

for(int i=0;i<3;i++)

{

for(int j=0;j<3;j++)

{

A[i][j]=(int)(20*Math.random());

}

}

System.out.println("display matrix 3 * 3");

for(int i=0;i<3;i++)

{

for(int j=0;j<3;j++)

{

System.out.print(A[i][j]+" ");

}

System.out.println();

}

}

}

output:


D:\JavaPrograms\ArrayPrograms>javac disparray.java

D:\JavaPrograms\ArrayPrograms>java disparray
3 * 3 matrix values are generated by random()
display matrix 3 * 3
15 8 14
2 6 7
6 18 17

D:\JavaPrograms\ArrayPrograms>java disparray
3 * 3 matrix values are generated by random()
display matrix 3 * 3
3 3 10
7 7 9
14 11 18