java类中调用函数_java – 从同一个类中的方法调用构造函数

我是

java新手,我正在学习创建对象类.我的一个家庭作业要求我在同一个对象类的方法中至少调用一次构造函数.我收到一条错误,说明DoubleMatrix类型未定义方法DoubleMatrix(double [] [])

这是我的构造函数:

public DoubleMatrix(double[][] tempArray)

{

// Declaration

int flag = 0;

int cnt;

// Statement

// check to see if doubArray isn't null and has more than 0 rows

if(tempArray == null || tempArray.length < 0)

{

flag++;

}

// check to see if each row has the same length

if(flag == 0)

{

for(cnt = 0; cnt <= tempArray.length - 1 || flag != 1; cnt++)

{

if(tempArray[cnt + 1].length != tempArray[0].length)

{

flag++;

}

}

}

else if(flag == 1)

{

makeDoubMatrix(1,1);// call makeDoubMatrix method

}

}// end constructor 2

这是我尝试调用构造函数的方法:

public double[][] addMatrix(double[][] tempDoub)

{

// Declaration

double[][] newMatrix;

int rCnt,cCnt;

//Statement

// checking to see if both are of same dimension

if(doubMatrix.length == tempDoub.length &&

doubMatrix[0].length == tempDoub[0].length)

{

newMatrix = new double[doubMatrix.length][doubMatrix[0].length];

// for loop to add matrix to a new one

for(rCnt = 0; rCnt <= doubMatrix.length; rCnt++)

{

for(cCnt = 0; cCnt <= doubMatrix.length; cCnt++)

{

newMatrix[rCnt][cCnt] = doubMatrix[rCnt][cCnt] + tempDoub[rCnt][cCnt];

}

}

}

else

{

newMatrix = new double[0][0];

DoubleMatrix(newMatrix)

}

return newMatrix;

}// end addMatrix method

有人能指出我正确的方向,并解释为什么我收到错误?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值