class Matrix{
public int myArray2[][];
public void Matrix(){
    myArray2=new int[9][9];
}
public void Matrix(int n){
myArray2=new int[n-1][n-1];
for(int i=0;i<n-1;i++){
for(int j=0;j<n-1;j++){
myArray2[i][j]=(int)Math.random();
}
}
}
public void Matrix(int n,int m){
myArray2=new int[n-1][m-1];
for(int i=0;i<n-1;i++){
for(int j=0;j<m-1;j++){
myArray2[i][j]=(int)Math.random();
}
}
}
public void Matrix(int table[][]){
for(int i=0;i<table.length;i++){
for(int j=0;j<table[i].length;j++){
myArray2[i][j]=(int)Math.random();
}
}
}
public void output(){
for(int i=0;i<myArray2.length;i++){
for(int j=0;j<myArray2[i].length;j++){
System.out.print(" "+myArray2[i][j]+" ");
System.out.println();
}
}
}
}
public class MatrixTest{
public static void main(String args[]){
Matrix a=new Matrix(3);
a.output();
}
}报错:
cannot resolve symbol
symbol  : constructor Matrix (int)
location: class Matrix
                Matrix a=new Matrix(3);
请大哥大姐帮忙看看哪错了?小弟刚学JAVA,谢谢!
另外需要在class Matrix中+2个方法:
public void transpose() //求一个矩阵的转置矩阵
public boolean isTriangular() //判断一个矩阵是否为上三角矩阵
方便的话一起帮我解决了 谢谢!

解决方案 »

  1.   


    Matrix类的构造方法如下:
    public void Matrix(){
        myArray2=new int[9][9];
    }
    public void Matrix(int n){
    myArray2=new int[n-1][n-1];
    for(int i=0;i<n-1;i++){
    for(int j=0;j<n-1;j++){
    myArray2[i][j]=(int)Math.random();
    }
    }
    }
    public void Matrix(int n,int m){
    myArray2=new int[n-1][m-1];
    for(int i=0;i<n-1;i++){
    for(int j=0;j<m-1;j++){
    myArray2[i][j]=(int)Math.random();
    }
    }
    }
    public void Matrix(int table[][]){
    for(int i=0;i<table.length;i++){
    for(int j=0;j<table[i].length;j++){
    myArray2[i][j]=(int)Math.random();
    }
    }
    }
    ----------------------------------------------------------------------------

    构造方法不应有返回值
    而楼主的代码中,构造方法都有返回值(void)
      

  2.   

    cannot resolve symbol
    symbol  : constructor Matrix (int)
    location: class Matrix
                    Matrix a=new Matrix(3);
    -------------------------
    这个错误提示意思是说:Matrix 没有带参数列表的构造方法
      

  3.   

    constructor不需要返回值。
    把所有的
    public void Matrix(.....
    改成
    public Matrix(.....
      

  4.   

    cannot resolve symbol
    symbol  : constructor Matrix (int)
    location: class Matrix
                    Matrix a=new Matrix(3);
    -------------------------
    没有适合的构造函数
    你的类里面只有一个extends Object的构造函数而已,其他的方法都是不是构造函数,去掉void
      

  5.   

    去掉Void  构造方法 没有返回值!
      

  6.   

    public class Matrix{
    public int myArray2[][];
    public Matrix(){
        myArray2=new int[9][9];
    }
    public Matrix(int n){
    myArray2=new int[n-1][n-1];
    for(int i=0;i<n-1;i++){
    for(int j=0;j<n-1;j++){
    myArray2[i][j]=(int)(Math.random() * 10);
    }
    }
    }
    public Matrix(int n,int m){
    myArray2=new int[n-1][m-1];
    for(int i=0;i<n-1;i++){
    for(int j=0;j<m-1;j++){
    myArray2[i][j]=(int)(Math.random() * 10);
    }
    }
    }
    public Matrix(int table[][]){
    for(int i=0;i<table.length;i++){
    for(int j=0;j<table[i].length;j++){
    myArray2[i][j]=(int)(Math.random() * 10);
    }
    }
    }
    public void output(){
    for(int i=0;i<myArray2.length;i++){
    for(int j=0;j<myArray2[i].length;j++){
    System.out.print(" "+myArray2[i][j]+" ");
    }
    System.out.println();
    }
    }
    public static void main(String args[]){
    Matrix a=new Matrix(4);
    a.output();
    }
    }
      

  7.   


    对,构造函数是不能由任何的返回类型修饰
    这和返回值为void不同