我帮你修改如下:
class Car
{
private String color;
private int speed;
public Car(String color)
{
this.color = color;
this.speed = 40;
System.out.println("我是父类的构造函数");
}
}
class Hummer extends Car
{
public Hummer(String color)
{
super(color);
//this.speed = 60;
System.out.println("我是子类的构造函数");
}
}
class GenericDemo
{
public static void main(String[] args)
{
Hummer h=new Hummer("red");
}
} |