1515 - [ 访问字段和静态变量] ( #访问字段和静态变量 )
1616 - [ 访问默认接口方法] ( #访问默认接口方法 )
1717 - [ 内置函数式接口\( Built-in Functional Interfaces\) ] ( #内置函数式接口built-in-functional-interfaces )
18- - [ Predicates ] ( #predicates )
19- - [ Functions ] ( #functions )
20- - [ Suppliers ] ( #suppliers )
21- - [ Consumers ] ( #consumers )
22- - [ Comparators ] ( #comparators )
23- - [ Optionals ] ( #optionals )
18+ - [ Predicate ] ( #predicate )
19+ - [ Function ] ( #function )
20+ - [ Supplier ] ( #supplier )
21+ - [ Consumer ] ( #consumer )
22+ - [ Comparator ] ( #comparator )
23+ - [ Optional ] ( #optional )
2424 - [ Streams\( 流\) ] ( #streams流 )
2525 - [ Filter\( 过滤\) ] ( #filter过滤 )
2626 - [ Sorted\( 排序\) ] ( #sorted排序 )
@@ -287,7 +287,7 @@ JDK 1.8 API包含许多内置函数式接口。 其中一些借口在老版本
287287
288288但是 Java 8 API 同样还提供了很多全新的函数式接口来让你的编程工作更加方便,有一些接口是来自 [ Google Guava] ( https://code.google.com/p/guava-libraries/ ) 库里的,即便你对这些很熟悉了,还是有必要看看这些是如何扩展到lambda上使用的。
289289
290- #### Predicates
290+ #### Predicate
291291
292292Predicate 接口是只有一个参数的返回布尔类型值的 ** 断言型** 接口。该接口包含多种默认方法来将 Predicate 组合成其他复杂的逻辑(比如:与,或,非):
293293
@@ -340,7 +340,7 @@ Predicate<String> isEmpty = String::isEmpty;
340340Predicate<String > isNotEmpty = isEmpty.negate ();
341341```
342342
343- #### Functions
343+ #### Function
344344
345345Function 接口接受一个参数并生成结果。默认方法可用于将多个函数链接在一起(compose, andThen):
346346
@@ -382,7 +382,7 @@ Function<String, String> backToString = toInteger.andThen(String::valueOf);
382382backToString.apply ("123 "); // "123"
383383```
384384
385- #### Suppliers
385+ #### Supplier
386386
387387Supplier 接口产生给定泛型类型的结果。 与 Function 接口不同,Supplier 接口不接受参数。
388388
@@ -391,7 +391,7 @@ Supplier<Person> personSupplier = Person::new;
391391personSupplier.get (); // new Person
392392```
393393
394- #### Consumers
394+ #### Consumer
395395
396396Consumer 接口表示要对单个输入参数执行的操作。
397397
@@ -400,7 +400,7 @@ Consumer<Person> greeter = (p) -> System.out.println("Hello, " + p.firstName);
400400greeter.accept (new Person ("Luke ", "Skywalker "));
401401```
402402
403- #### Comparators
403+ #### Comparator
404404
405405Comparator 是老Java 中的经典接口, Java 8 在此之上添加了多种默认方法:
406406
@@ -414,9 +414,9 @@ comparator.compare(p1, p2); // > 0
414414comparator.reversed ().compare (p1 , p2 ); // < 0
415415```
416416
417- ## Optionals
417+ ## Optional
418418
419- Optionals 不是函数式接口 ,而是用于防止 NullPointerException 的漂亮工具。这是下一节的一个重要概念,让我们快速了解一下 Optionals 的工作原理 。
419+ Optional 不是函数式接口 ,而是用于防止 NullPointerException 的漂亮工具。这是下一节的一个重要概念,让我们快速了解一下 Optional 的工作原理 。
420420
421421Optional 是一个简单的容器,其值可能是null 或者不是null 。在Java 8 之前一般某个函数应该返回非空对象但是有时却什么也没有返回,而在Java 8 中,你应该返回 Optional 而不是 null 。
422422
0 commit comments