新手在线求救

陌路彼此 2018-07-17 04:09:11
public class InterfaceTester {

public static void main(String[] args) {
// TODO Auto-generated method stub
Rectangle rect= new Rectangle (5,6);
System.out.println("Are of rect = " + rect.area());
Circle cir = new Circle(2.0);
System.out.println("Area of cir = " + cir.area());
}

}
interface Shape2D {
double pi=3.14;
double area ();
}
class Circle implements Shape2D {
private double redius;
public Circle (double r) { //构造方法
redius = r;
}
public double area() {
return (pi * redius * redius);
}
}
class Rectangle implements Shape2D {
int width,height;
public Rectangle (int w,int h) {
width =w;
int height = h;
}
public double area() {
return (width * height);
}
}
运行后出现错误Exception in thread "main" java.lang.NoSuchMethodError: zhouer1.Circle.<init>(D)V
at zhouer1.InterfaceTester.main(InterfaceTester.java:9)
求大佬解答!
...全文
175 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
遇见1995 2018-07-18
  • 打赏
  • 举报
回复

我这运行没问题,楼主是运行了其他类的main方法吗?
verejava 2018-07-18
  • 打赏
  • 举报
回复
没有看见有 zhouer1.Circle
Vilen7 2018-07-17
  • 打赏
  • 举报
回复
你这个代码我运行的没问题呀,你是不是run错了main方法呀

62,612

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧