指点一下,运行结果提示:Exception in thread "main" java.lang.NoSuchMethodError: main

ricky_zh 2012-06-11 09:50:15
请高手指点一下,这个程序那里出错了,运行结果提示:Exception in thread "main" java.lang.NoSuchMethodError: main

public class Rectangle {
public int x, y;
private int m, n;
public Rectangle(){
x=10;
y=20;
m=100;
n=50;
System.out.println("x=" +x);
System.out.println("y=" +y);
}

public void measure(){
int s;
s=m*n;
System.out.println("result=" +s);
}
void show(){
System.out.println("x" +x + "y" +y);
}

}
class Shape extends Rectangle{
public static void main (String[] args){
int width =30, height=20;
Shape r = new Shape();
r.x=width;
r.y=height;
r.measure();
}
}
...全文
384 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
jlu_lamp_lamp 2012-06-12
  • 打赏
  • 举报
回复
意思就是你的public class的类没有main方法
brightyq 2012-06-11
  • 打赏
  • 举报
回复
main方法写到public的类里面。
像你这种写法,就把Shape单独写到一个文件中去吧,然后换成是
public class Shape extends Rectangle{
}
往下都一样。
dazhanhongtao 2012-06-11
  • 打赏
  • 举报
回复
将public class Rectangle该为class Rectangle
将class Shape extends Rectangle改为public class Shape extnds Rectangle

62,614

社区成员

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

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