if (vehicle instanceof Car) {
Car car = (Car) vehicle;
return car.wheelCount;
} else if (vehicle instanceof Bike) {
Bike bike = (Bike) vehicle;
return bike.numberOfWheels;
} else {
throw new IllegalArgumentException("Unrecognized vehicle");
}
if (vehicle instanceof Car car) {
return car.wheelCount;
} else if (vehicle instanceof Bike bike) {
return bike.numberOfWheels;
} else {
throw new IllegalArgumentException("Unrecognized vehicle");
}