四大内置函数式接口
消费型接口
特点:有参数,没有返回值
Consumer<Integer> con = s-> System.out.println("我今天消费了"+s);
con.accept(2000);
函数型接口
特点:有一个参数,有一个返回值
Function<String,String> fun = a-> a.toUpperCase();
System.out.println(fun.apply("adsd"));
段言型接口
特点:有一个参数,返回值式布尔类型
Predicate<String> pre = a -> a.length()>3;
System.out.println(pre.test("ssad"));
供给型接口
特点:没有参数,有返回值
Supplier supplier = ()->(int)(Math.random()*3);
System.out.println(supplier.get());