Skip to content

Commit 7980d03

Browse files
authored
集合转Map抛出异常的常见情形提醒
1 parent 6f3f2c9 commit 7980d03

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

docs/java/collection/java-collection-precautions-for-use.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ public static <T> T requireNonNull(T obj) {
134134
return obj;
135135
}
136136
```
137+
> `Collectors`也提供了无需mergeFunction的`toMap()`方法,但此时若出现key冲突,则会抛出`duplicateKeyException`异常,因此强烈建议使用`toMap()`方法必填mergeFunction。
137138
138139
## 集合遍历
139140

0 commit comments

Comments
 (0)