我可以让类的静态字段保持对其自身实例的引用吗?如果是这样,它会在jvm中保持活着而没有其他人保留引用吗?
public class StatTest {
private static StatTest statTest;
public static StatTest getStatTest () {
if (statTest== null) {
statTest= new StatTest ();
statTest.init();
}
return statTest;
}
private StatTest() { }
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1822 次 |
| 最近记录: |