供给型接口
Supplier<String> s = new Supplier<String>() {
@Override
public String get() {
return "你好";
}
}
Supplier<String> s1 = () -> "你好啊";
功能型接口
map.replaceAll(new BiFunction<Integer, String, String>() {
@Override
public String apply(Integer integer, String s) {
if(s.startsWith("李")) {
return "啦啦啦";
}
return null;
}
})
map.replaceAll((a, b) -> {
if(b.startsWith("李")) {
return "啦啦啦";
}
return null;
});
判断型接口
list.removeIf(new Predicate<String>() {
@Override
public boolean test(String s) {
if(s.startsWith("李")) {
return true;
}
return false;
}
})
list.removeIf((s) -> {
return s.startsWith("李") ? true : false;
});