javascript
Brief description  about Online courses   join in Online courses
View ISHAN  GUPTA 's Profile

Display of matrices by using various methods

There was a question somewhere on the net that I had to display matrices using different constructors as in default type, input parameter as matrix, input parameter as object instance of that matrix but I am getting a run time error . The program is as follows

class MatrixEx1{
int mat[][];
MatrixEx1() {
int i,j;
int row=3;
int col=3;
mat=new int[3][3];
for(i=0;i<row;i ) {
for(j=0;j<col;j ) {
mat[i][j]=i*j;
System.out.println(mat[i][j]);
}
}}
MatrixEx1(int r, int c) {
int i,j;

for (i=0;i<r;i ) {
for(j=0;j<c;j ) {
mat[i][j]=1;
System.out.println(mat[i][j]);
}
}}
MatrixEx1(int mat1[][]) {
int r=mat1.length;
int c=mat1[0].length;
for (int i=0; i<r;i )
{
for(int j=0;j<c;j ) {
mat[i][j]=mat1[i][j];
System.out.println(mat[i][j]);
}
System.out.println(" ");
} }
MatrixEx1(MatrixEx1 m1) {
int r=m1.mat.length;
int c=m1.mat[0].length;
for (int i=0;i<r;i )
{
for(int j=0;j<c;j )
{
mat[i][j]=m1.mat[i][j];
System.out.println(mat[i][j]);
}
} }
}

class MainClasss {
public static void main(String args[]) {
int m3[][] = {{1,3,5},{2,3,1},{4,5,6}};
MatrixEx1 m1=new MatrixEx1(m3);
MatrixEx1 m2=new MatrixEx1(MatrixEx1 m1);
} }



The errors are:
MatrixEx1 m2=new MatrixEx1(MatrixEx1 m1);
^
MainClasss.java:51: illegal start of expression
MatrixEx1 m2=new MatrixEx1(MatrixEx1 m1);


Can you please rectify this program?





Asked by ISHAN GUPTA | Aug 26, 2012 |  Reply now
Replies (3)
View java teacher 's Profile
U can check your mail_id. The answer is there..
Sep 5, 2012
View ishan gupta 's Profile
Where is it?
Aug 31, 2012
View java teacher 's Profile
Something wrong you have done, no issue i rectified it.
Aug 31, 2012