1,java
@FunctionalInterface
public interface Supplier<T> {編程
2, T get();併發
3,app
Supplier<Apple> c1 = Apple::new
Apple a1 = c1.get();函數
1,優化
@FunctionalInterface
public interface Consumer<T> {blog
2,void accept(T t);接口
3,主要用來輸出的ip
1,public interface Function<T, R> {資源
2,T apply(F input);
3,主要是用來轉換東西的
4,函數複合,
1,充當一個參數化的返回Boolean比較方法
2,public interface Predicate<T> {
3,boolean test(T t);
4,能動態替換返回boolean的函數
5,基本類型裝箱問題,
DoublePredicate
boolean test(double value);//有對應的原始類型特化接口
6,謂詞複合,優先級從左到右a.or(b).and(c) == (a || b )&& c
1,
2,
3,
4,基本lambda語法
5,基本用法
6,在面向資源編程的lambda,不須要重複打開資源和關閉資源
7,lambda也有匿名函數的問題
8,方法引用
9,比較器複合
1,更加簡單的利用多cpu
2,基本概念
6,查找和匹配
.noneMatch(d -> d.getCalories() >= 1000);
7,歸約
最大最小值:Optional min = numbers.stream().reduce(Integer::min);
8,併發的有狀態和無狀態
9,優化自動裝箱,
IntStream intStream = menu.stream().mapToInt(Dish::getCalories)
Stream<Integer> stream = intStream.boxed();
10,小結
11,collect
1,default <V> Function<V, R> compose(Function<? super V, ? extends T> before) {
能夠添加默認實現
2,在 java8 中的接口中不只增長了默認方法,還增長了靜態方法。使用方式接口名.方法名。
3,
@FunctionalInterface
public interface Runnable {代表是個函數接口
1,策略模式,相似predicate替換策略
2,模板方法,
3,觀察者模式,註冊的時候寫上方法
4,責任鏈模式,在註冊的時候像觀察者模式差很少
5,傳統簡單工廠,用map和supplier