多态 传值的一个问题
package poly;
class Glyph{
void draw(){
System.out.println("Glyoh.draw()");;
}
Glyph(){
System.out.println("Glyph() before draw()");
draw();
System.out.println("Glyph() after draw()");
}
}
class RoundGlyph extends Glyph{
private int radius = 1;
public RoundGlyph(int i) {
// TODO Auto-generated constructor stub
radius = i;
System.out.println("RoundGlyph.RoundGlyph().radius = "+radius);
}
void draw(){
System.out.println("RoundGlyph.draw().radius = "+radius); //这里为什么输出的是0,不太懂。怎么会是0呢
}
}
public class PolyCjonstructors {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
new RoundGlyph(5);
}
}