【发布时间】:2021-06-24 06:41:20
【问题描述】:
我在下面的链接中,在第 5 步,在服务定位器设计模式指南中发现了这种用法 https://www.tutorialspoint.com/design_pattern/service_locator_pattern.htm
我不明白他们为什么使用这种结构。
public class ServiceLocator {
private static Cache cache;
static {
cache = new Cache();
}
}
对
private static Cache cache = new Cache();
【问题讨论】:
标签: java variables initialization declaration