mirror of
https://github.com/Snailclimb/JavaGuide
synced 2025-06-16 18:10:13 +08:00
commit
d3bcbd60b2
@ -134,6 +134,7 @@ public static <T> T requireNonNull(T obj) {
|
||||
return obj;
|
||||
}
|
||||
```
|
||||
> `Collectors`也提供了无需mergeFunction的`toMap()`方法,但此时若出现key冲突,则会抛出`duplicateKeyException`异常,因此强烈建议使用`toMap()`方法必填mergeFunction。
|
||||
|
||||
## 集合遍历
|
||||
|
||||
|
@ -60,7 +60,7 @@ public class Singleton {
|
||||
private Singleton() {
|
||||
}
|
||||
|
||||
public static Singleton getUniqueInstance() {
|
||||
public static Singleton getUniqueInstance() {
|
||||
//先判断对象是否已经实例过,没有实例化过才进入加锁代码
|
||||
if (uniqueInstance == null) {
|
||||
//类对象加锁
|
||||
|
Loading…
x
Reference in New Issue
Block a user