I currently have a Supercar
class that extends a Car
class, and want to downcast an array of Car
class.
System.out.println("\nLab Task 6");
Car[] cars = new Car[10]; //object array
cars[0] = new SuperCar( model: "Lambo", cc: 8000, type: "Car", transmission: "Manual", powertrain: "Electric", maxSpeed: 300);
cars[1] = new SuperCar( model: "BMW", cc: 4500, type: "Car", transmission: "Manual", powertrain: "Electric", maxSpeed: 200);
Supercar superD = (SuperCar)cars[];
Is that any problem or error inside the code?