mirror of
https://github.com/Snailclimb/JavaGuide
synced 2025-06-16 18:10:13 +08:00
集合转Map抛出异常的常见情形提醒
This commit is contained in:
parent
6f3f2c90fe
commit
7980d03265
@ -134,6 +134,7 @@ public static <T> T requireNonNull(T obj) {
|
||||
return obj;
|
||||
}
|
||||
```
|
||||
> `Collectors`也提供了无需mergeFunction的`toMap()`方法,但此时若出现key冲突,则会抛出`duplicateKeyException`异常,因此强烈建议使用`toMap()`方法必填mergeFunction。
|
||||
|
||||
## 集合遍历
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user