为什么我的运营商会说“无效字符”?

时间:2015-11-29 21:45:33

标签: java

为什么我的运营商会说“无效字符”? 我正试图返回我的三角区域,所以我使用了这个等式。

public double getArea() {

    double x = (getSide1() + getSide2() + getSide3()) /2;

    double answer = x - ­ getSide1();

    answer = answer * x;

    answer = answer * (x - ­getSide2());

    answer = answer * (x ­- getSide3());

    answer = Math.sqrt(Math.abs(answer));

    return answer;

}

public void setArea(double area) {

    this.area = area;

}

1 个答案:

答案 0 :(得分:1)

这是Java,而不是JavaScript。 x之后没有操作员。这就是原因。此外,这看起来更像是编码问题,因为-的字符与不同。

public double getArea() {
    double x = (getSide1() + getSide2() + getSide3()) /2;
    double answer = x -­ getSide1();
    answer = answer * x;
    answer = answer * (x -­ getSide2());
    answer = answer * (x ­- getSide3());
    answer = Math.sqrt(Math.abs(answer));
    return answer;
}

public void setArea(double area) {
    this.area = area;
}