我有一个抽象类
public abstract class Car {
private int carId;
public Car(int carId) {
this.carId = carId;
}
public int getCarId(c) {
return carId;
}
public void setCarId(int carId) {
this.carId = carId;
}
}
public class Jeep extends Car {
private String jeepModel;
public Jeep(int carId) {
super(carId);
}
public String getJeepModel() {
return this.jeepModel;
}
public setJeepModel(String jeepModel) {
this.jeepModel = jeepModel;
}
}
public class AbstractClassExample {
public Car car;
public static void main(String[] args) {
car = new Jeep(1);
}
}
当我这样做时,我收到以下错误:类型不匹配:无法从 Jeep 转换为 Car
我在这里做错了什么?