class Point { Point() {
System.out.println(this.getClass().getName());
}
}public class ColorPoint extends Point {
ColorPoint() { super(); }
public static void main(String[] args) { new ColorPoint(); }}结果:ColorPoint
super()只是调用了基类的构造方法,为什么this是ColorPoint类???super是不是基类的一个实例,在子类中调用super()有什么用??
System.out.println(this.getClass().getName());
}
}public class ColorPoint extends Point {
ColorPoint() { super(); }
public static void main(String[] args) { new ColorPoint(); }}结果:ColorPoint
super()只是调用了基类的构造方法,为什么this是ColorPoint类???super是不是基类的一个实例,在子类中调用super()有什么用??
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货