public class Main {
public static void main(String[] args){
new Circle("my");
}
}
class Draw {
public Draw(String type) {
System.out.println(type+" draw constructor");
}
}
class Shape {
private Draw draw = new Draw("shape");
public Shape(){
System.out.println("shape constructor");
}
public Shape(String str){
System.out.println(str+"shape constructor");
}
}
class Circle extends Shape {
private Draw draw = new Draw("circle");
public Circle() {
System.out.println("circle constructor");
}
public Circle(String str){
super(str);
System.out.println(str+"circle constructor");
}
}
输出结果:
shape draw constructor
myshape constructor
circle draw constructor
mycircle constructor