java程序为什么会报错了还能运行?

public float getCircum(float r) { throw new UnsupportedOperationException("Not supported yet.");} public void draw() { throw new UnsupportedOperationException("Not supported yet.");} 显然你没有实现所有的方法,可程序依然有错 再一细看 public float getArea(float r){ float area= ...
java程序为什么会报错了还能运行?
你不妨将Circ 这个类中,除了main方法之外的所有方法都删了,这样你会得到提示,要求你实现所有 抽象方法,
这时你按系统提示的解决方法 :添加如下三个方法:
public float getAtea(float r) {
throw new UnsupportedOperationException("Not supported yet.");
}

public float getCircum(float r) {
throw new UnsupportedOperationException("Not supported yet.");
}

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

显然你没有实现所有的方法,可程序依然有错
再一细看
public float getArea(float r){
float area= Calculate.PI*r*r;
return area;
}
public float getCirccum(float r){
float circum=Calculate.PI*2*r;
return circum;
}

你的方法错了....
float getAtea(float r);

public float getArea(float r){
float area= Calculate.PI*r*r;
return area;
}

楼主现在明白了。。。

就是类没有实现你所继承的接口的方法,你在类中写的两个方法都不是继承自接口的2010-06-23
你的main()函数中的 circ.getCirccum(r); 应该是getCircum,你的多了个c。

你的这个程序不知一点问题,Circ类中没有实现第一个接口的getAtea();只是实现GeomdtryShape接口的final方法。2010-06-23
因为你Circ类实现了Calculate GeomdtryShape两个接口,所以就必须重写这两个接口中定义的所有方法2010-06-22
mengvlog 阅读 1278 次 更新于 2025-12-18 08:11:28 我来答关注问题0
檬味博客在线解答立即免费咨询

报错相关话题

Copyright © 2023 WWW.MENGVLOG.COM - 檬味博客
返回顶部