public class Demo01 {
public static void main(String[] args) {
Function<String, Integer> function = s -> {
return s.length();
};
System.out.println(function.apply("aa"));
}
public class Demo02 {
public static void main(String[] args) {
Predicate<String> predicate = (str) -> {
return str.isEmpty();
};
System.out.println(predicate.test("a"));
}
public class Demo03 {
public static void main(String[] args) {
Supplier<String> supplier = () -> {
return "a";
};
System.out.println(supplier.get());
Consumer<String> consumer = (s) -> {
System.out.println(s);
};
System.out.println(consumer);
}
JUC四个函数式接口
点赞
收藏