I'm trying to create a "Truck" using downcasting from the parent class (Truck extends Car)
private Truck truck;
public void createTruck() {
Car basicCar = new Car();
this.truck = (Truck) basicCar;
}
But for some reason Intellij IDEA spots a problem
Casting 'basicCar' to 'Truck' will produce 'ClassCastException'for any non-null value
What have I done wrong?