📅  最后修改于: 2022-03-11 14:52:36.196000             🧑  作者: Mango
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");
}