Java 8 中的 Streams API 详解
https://www.ibm.com/developerworks/cn/java/j-lo-java8streamapi/index.html
https://www.jianshu.com/p/a3855f880ff2
https://unmi.cc/java-8-lambda-capture-outer-variables/
http://blog.oneapm.com/apm-tech/226.html
http://www.cnblogs.com/CarpenterLee/p/6550212.html
https://engineering.shoutapp.io/a-tale-of-method-reference-ambiguity-e51d3c5d9b00
http://www.cnblogs.com/CarpenterLee/p/6545321.html
Java Stream API进阶篇
http://www.cnblogs.com/CarpenterLee/p/6550212.html
Java 8系列之Stream的基本语法详解
https://blog.csdn.net/io_field/article/details/54971761
JDK8 Stream 从入门到装逼(三)
https://my.oschina.net/kaishui/blog/743383
https://stackoverflow.com/questions/24010109/java-8-stream-reverse-order
https://blog.csdn.net/u011001723/article/details/52794455
https://stackoverflow.com/questions/53645037/will-parallel-stream-work-fine-with-distinct-operation
并行流与 distinct() 可正常搭配,但需要等全部并行流执行完。
IntStream.of(1, 1, 2, 2, 3, 3, 3, 4, 4)
.parallel()
.distinct()
.forEach(System.out::println);
结果是 1,2,3,4
https://stackoverflow.com/questions/30382453/java-stream-sort-2-variables-ascending-desending
JAVA8 Stream之Sort排序comparing 和thenComparing
https://blog.csdn.net/YoungLee16/article/details/83547713
https://blog.csdn.net/lmy86263/article/details/51057733
Move to next item using Java 8 foreach loop in stream
https://stackoverflow.com/questions/32654929/move-to-next-item-using-java-8-foreach-loop-in-stream
https://stackoverflow.com/questions/38998514/when-should-i-use-intstream-range-in-java
LeetCode.1431.Kids With the Greatest Number of Candies 拥有最多糖果的孩子
https://www.cnblogs.com/gaohanghang/p/12390233.html
https://zacard.net/2016/03/17/java8-list-to-map/
https://my.oschina.net/kaishui/blog/754915
https://blog.csdn.net/zh15732621679/article/details/80483617
- Lambda表达式
- Java8中lambda表达式无法抛出受检异常
- lambda表达式(内部类)中只能访问final局部变量
- 函数式接口
- 接口的静态方法和默认方法
- 方法引用
- No compile-time declaration for the method reference is found
- 常用函数式接口
- Function<T,R>
- Predicate<T>
- BiFunction<T, U, R>
- Stream 接口
- Stream反转列表
- generate() 生成单元素无限序列
- iterate() 生成无限序列
- parallelStream()
- 修改并行流的线程数
- 并行流可正常distinct()操作
- anyMatch()
- allMatch()
- peek()
- findFirst()
- findAny()
- map()
- flatMap()
- filter()
- collect后才起作用
- Objects::nonNull 过滤null元素
- distinct()
- distinct().count() 判断元素是否重复
- sorted()
- 默认自然排序(字典序)
- Comparator.reverseOrder() 自然序逆序
- Comparator.comparing() 单字段正序排序
- Comparator.comparing() 单字段倒叙排序
- Comparator.comparing().thenComparing() 多字段排序
- 多字段排序一个升序一个降序
- forEach()
- Java8 foreach()中return相当于continue
- foreach遍历Map
- Java8 Map转List
- foreach遍历List
- IntStream
- IntStream.range()
- IntStream.rangeClosed()
- IntStream.mapToObj()
- sum()求和
- max()/min() 最大最小值
- max()/min() 的错误用法
- reduce()
- collect()
- Collectors
- toList() 与 collect(Collectors.toList())
- Collectors.toMap()
- 使用Java8的Stream把List转为Map
- Collectors.toMap() 指定Map类型
- Collectors.toMap() 重复value任取其一
- Collectors.toMap() 重复value选择最新的
- Collectors.toMap() 重复value构成List
- Collectors.joining(“,”) 转逗号分隔字符串
- Collectors.counting()
- Collectors.collectingAndThen()
- TreeSet多字段去重
- TreeSet排序和多字段去重
- Collectors.groupingBy()
- 分组后构成List
- 分组后统计个数
- 分组后做map
- 分组到按key有序的TreeMap