代码运行不通, 我GOOGLE了, 说是没main方法, 事实上我是写了main的,求大虾看看, 先谢了!不是吝啬分, 是想留着多问几个问题, 不想用申请N个马甲, 不过我相信你们不是为了分才来论坛的。 : )
- Java code
package study.javase.test;abstract class Shape { public final double PI = 3.14; public Shape() { System.out.println("A shape was create."); } void draw() { System.out.println("Draw a shape"); } // abstract method abstract double area();}//class Circle extends Shape { int xpos; int ypos; int radius; public Circle() { super(); } public Circle(int x, int y, int r) { super(); xpos = x; ypos = y; radius = r; } public void draw() { System.out.println("draw a circle"); } public double area() { return PI*radius*radius; }}//class Rectangle extends Shape { int left; int top; int width; int height; public Rectangle() { super(); } public Rectangle(int l, int t, int w, int h) { super(); left = l; top = t; width = w; height = h; } public double area() { return width*height; }}public class Abstract { public static void main(String args[]) { Shape rec = new Rectangle(0, 0, 40, 30); System.out.println(rec.area()); rec.draw(); Shape sha = new Circle(120, 130, 50); System.out.println(sha.area()); sha.draw(); }}
------解决方案--------------------
public static void main(String[] args)
------解决方案--------------------
敢问你java文件的文件名是啥? 是不是 Abstract.java ? 如果不是请修正。
------解决方案--------------------
我怎么也没看出有什么问题!我也用你的代码运行了下,也是可以运行的!
你运行的类文件名字是叫Abstract?
------解决方案--------------------
呃,把报错的具体内容贴出来……
------解决方案--------------------