java基础-多态性
2018-04-19 本文已影响3人
李2牛
- 测试案例:
Circle.java
abstract class Shape{
public abstract void draw();
Shape(){
System.out.println("start draw()");
draw();
System.out.println("finish draw()");
}
}
public class Circle extends Shape{
public int radius = 1;
public void draw(){
System.out.println(radius);
}
Circle(int radius){
this.radius = radius;
}
public static void main(String[] args){
new Circle(5);
}
}