Skip to content

Commit 8f330ae

Browse files
author
chenyong
committed
docs(stream): add note about java stream group by
1 parent e6bee01 commit 8f330ae

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

java/basic/java-collection.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
* [Collections工具类-操作集合]()
4343
* [Arrays工具类-操作数组]()
4444
* [5. 圈重点](#5.圈重点)
45+
* [6. Stream](#6.Stream)
4546

4647
* [参考资料](#参考资料)
4748

@@ -1123,6 +1124,12 @@ List list = Arrays.asList(1, 2, 3);
11231124
* Collection集合用于存Object的,不支持存储基础数据类型,这是由Collection接口的定义决定的: Collection<E>
11241125
* iterator.remove()方法必须要在调用了next()方法之后,否则会报IllegalStateException
11251126

1127+
# 6.Stream
1128+
* List转map,按某个字段分类
1129+
```java
1130+
// group by City
1131+
Map<String, List<Employee>> employeesByCity = employees.stream().collect( Collectors.groupingBy(Employee::getCity));
1132+
```
11261133

11271134
# 参考资料
11281135
* 集合框架图 https://img-blog.csdn.net/20160124221843905

0 commit comments

Comments
 (0)