mirror of
https://github.com/sjsdfg/effective-java-3rd-chinese.git
synced 2025-03-29 05:20:29 +08:00
Update 03. 使用私有构造方法或枚类实现Singleton属性.md
This commit is contained in:
parent
c2e2b0eba1
commit
a0c1bc119e
@ -1,6 +1,5 @@
|
||||
# 3. 使用私有构造方法或枚类实现 Singleton 属性
|
||||
|
||||
---
|
||||
|
||||
单例是一个仅实例化一次的类[Gamma95]。单例对象通常表示无状态对象,如函数 (条目 24) 或一个本质上唯一的系统组件。让一个类成为单例会使测试它的客户变得困难,因为除非实现一个作为它类型的接口,否则不可能用一个模拟实现替代单例。
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user