You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
335 B
14 lines
335 B
public class TestVehicle {
|
|
public static void main(String[] args) {
|
|
// 创建Vehicle数组,存放不同车辆
|
|
Vehicle[] vehicles = new Vehicle[3];
|
|
vehicles[0] = new Car();
|
|
vehicles[1] = new Bike();
|
|
vehicles[2] = new Truck();
|
|
|
|
// 遍历数组,调用run()
|
|
for (Vehicle v : vehicles) {
|
|
v.run();
|
|
}
|
|
}
|
|
}
|