指点一下,运行结果提示:Exception in thread "main" java.lang.NoSuchMethodError: main
请高手指点一下,这个程序那里出错了,运行结果提示:Exception in thread "main" java.lang.NoSuchMethodError: mainpublic 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();
}
} --------------------编程问答-------------------- 将public class Rectangle该为class Rectangle
将class Shape extends Rectangle改为public class Shape extnds Rectangle --------------------编程问答-------------------- main方法写到public的类里面。
像你这种写法,就把Shape单独写到一个文件中去吧,然后换成是
public class Shape extends Rectangle{
}
往下都一样。 --------------------编程问答-------------------- 意思就是你的public class的类没有main方法
补充:Java , Java SE