为了账号安全,请及时绑定邮箱和手机立即绑定

为何此处会出现找不到symbol的错误呢?

为何此处会出现找不到symbol的错误呢?

扬帆大鱼 2019-03-23 18:11:42
使用this不是引用创建的对象么?import java.util.Comparator;import java.lang.Comparable;public class Point implements Comparable<Point> {    int x, y;    public final Comparator<Point> SLOPE_ORDER = new ByOrder();    private class ByOrder implements Comparator<Point> {        public int compare(Point one, Point two) {            return this.slopeTo(one) < this.slopeTo(two) ? -1:                    this.slopeTo(one) > this.slopeTo(two) ? 1:0;        }    }    public Point(int x, int y) {        this.x = x;        this.y = y;    }    public void draw() {        StdDraw.circle(x, y, 00);    }    public void drawTo(Point that) {        StdDraw.line(this.x, this.y, that.x, that.y);    }    public String toString() {        String point_string = '(' + String.valueOf(x) + ',' +                                     String.valueOf(y) + ')';        return point_string;    }    public int compareTo(Point that) {        return ((this.y < that.y) || (this.y == that.y && this.x < that.x)) ? -1:                (this.y > that.y) ? 1:0;    }    public double slopeTo(Point that) {        double slope = (that.y - this.y) / (that.x - this.x);        return slope;    }}Point.java:10: error: cannot find symbol return this.slopeTo(one) <this.slopeTo(two) ? -1:^ symbol: method slopeTo(Point)
查看完整描述

1 回答

?
海绵宝宝撒

TA贡献1809条经验 获得超8个赞

你的 this 是 ByOrder 对象,而 ByOrder 不在 Point 的继承树上


查看完整回答
反对 回复 2019-04-15
  • 1 回答
  • 0 关注
  • 508 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号