试图在另一个类中创建一个类对象

时间:2014-11-02 16:51:03

标签: java class object

我正在尝试将类点的对象创建到另一个类InterestPoint中,有些单词我希望能够在INterestPoint类中使用Points值但不使用遗传< / p>

public class InterestPoint {

    private Point p1;
    private String aeria;

    public InterestPoint() {
        this.p1 = new Point();
        //p1.dysplay1();
    }

}

修改

当你通过类功能调用我的方法打印我的观点时,你没有误解它给我打印的错误说:

Exception in thread "main" java.lang.UnsupportedOperationException: Not supported yet.
    at Point.dysplay1(Point.java:29)
    at InterestPoint.setall1(InterestPoint.java:22)
    at Main.main(Main.java:16)
Java Result: 1

这就是我发布这个问题的原因:D

1 个答案:

答案 0 :(得分:0)

回复:

Exception in thread "main" java.lang.UnsupportedOperationException: Not supported yet.
    at Point.dysplay1(Point.java:29)
    at InterestPoint.setall1(InterestPoint.java:22)
    at Main.main(Main.java:16)
Java Result: 1

拍摄,你没有向我们展示你的整个InterestPoint课程,特别是你所拥有的方法必须看起来像:

public void setAll1() {
   throw new UnsupportedOperationException("Not supported yet");
}

解决方案是摆脱抛出调用并输入有意义的代码。

public void setAll1() {
   // get rid of this throw exception call
   // throw new UnsupportedOperationException("Not supported yet");

   // add some sensible code here
}