Glyph(){
System.out.println(“Glyph() before draw()”);
draw();
System.out.println(“Glyph() after draw()”);
}
}
Class RoundGlyph extends Glyph{
private int radius=1;
RoundGlyph(int r ){
radius=r;
System.out.println(“RoundGlyph. RoundGlyph(),radius=”+radius);
}
void draw(){
System.out.println(“RoundGlyph.draw(),radius=”+radius);
}
}
public class PolyConstructors{
public static void main(Stringp[] args){
new RoundGlyph(5);
}
}
/*Output:
Glyph() before draw()
RoundGlyph.draw(),radius=0
Glyph() after draw()
RoundGlyph. RoundGlyph(),radius=5
*/ 作者: 沉湎码海 时间: 2017-2-10 22:27
受教啦!