// 汽车
class Car {
// 跑
public void run(Petrol petrol) {
System.out.println("使用:" + petrol.type + ", 汽车跑了起来~");
}
}
// 汽油
class Petrol {
// 构造
public Petrol(String type) {
this.type = type;
}
// 汽油型号
public String type;
}
public class YiLai {
public static void main(String[] args) {
// 使用场景
Car car = new Car();
car.run(new Petrol("93号汽油"));
}
}
Java 依赖关系
最新推荐文章于 2024-03-29 19:56:49 发布