【发布时间】:2017-03-21 13:48:45
【问题描述】:
我正在尝试创建一个类,该类将通过将数组作为输入(除其他外)来创建矩阵。这个数组将被分配给一个记录(Record9)。但是,在尝试编译时出现此错误。您可以在下面找到我的代码:
public class Matrix3x3flat {
private class Record9 {
public long r1c1;
public long r1c2;
public long r1c3;
public long r2c1;
public long r2c2;
public long r2c3;
public long r3c1;
public long r3c2;
public long r3c3;
}
private Record9 mat;
public Record9(long[] arr) {
Record9 this.mat = new Record9();
this.mat.r1c1 = arr[0];
this.mat.r1c2 = arr[1];
this.mat.r1c3 = arr[2];
this.mat.r2c1 = arr[3];
this.mat.r2c2 = arr[4];
this.mat.r2c3 = arr[5];
this.mat.r3c1 = arr[6];
this.mat.r3c2 = arr[7];
this.mat.r3c3 = arr[8];
return this.mat;
}
}
我不明白这个问题,但我怀疑这与我在 return 语句中没有正确引用 this.mat 有关。
【问题讨论】:
标签: java oop constructor