【发布时间】:2021-02-18 16:17:25
【问题描述】:
所以,这个接口有 2 个实现。我想用接口的所有实现来验证输入,并返回满足条件的实现对象。
界面:
interface SomeInterface {
boolean someCheck(int n);
}
实施 1:
public class SomeClass implements SomeInterface {
public boolean someCheck(int n) {
// returns true if n is less than 10
}
}
实施 2:
public class AnotherClass implements SomeInterface {
public boolean someCheck(int n) {
// returns true if n is greater than 10
}
}
我可以在这里使用依赖注入的概念吗?
【问题讨论】:
标签: java spring spring-boot dependency-injection