简单地说,我试图使用一种方法来做一个计算并返回计算。它说明两个无法弄清楚为什么java抛出返回类型错误
Invalid method declaration;return type required
Incompatible types;unexpected return value
这是类:
package shapes;
public class RectangleCalc {
private double length;
private double width;
}
public RectangleCalc(double length, double width){
this.length = length;
this.width = width;
}
public getArea() {
return length * width;
}
基本方法getArea()
是扔我上面列出的错误。我知道为什么。
getArea()方法的返回类型是什么? – rgettman
你在“私人双倍宽度”之后关闭了你的课程;还是它是一个错字? – injecteer