I am new to java and I will learn about creating object classes. One of my homework tasks requires me to call the constructor at least once in a method of the same object class. I get an errorThe method DoubleMatrix(double[][]) is undefined for the type DoubleMatrix
Here is my constructor:
public DoubleMatrix(double[][] tempArray)
{
int flag = 0;
int cnt;
if(tempArray == null || tempArray.length < 0)
{
flag++;
}
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);
}
}
Here is the method in which I try to call the constructor:
public double[][] addMatrix(double[][] tempDoub)
{
double[][] newMatrix;
int rCnt, cCnt;
if(doubMatrix.length == tempDoub.length &&
doubMatrix[0].length == tempDoub[0].length)
{
newMatrix = new double[doubMatrix.length][doubMatrix[0].length];
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;
}
Can someone point me in the right direction and explain why I get an error message?
source
share