如:
1. class Single{
2. //类已加载,对象就已经存在了
3. private static Single s = new Single();
4.
5. private Single(){}
6.
7. public static Single getInstance(){
8. return s ;
9. }
10. }
那么如何让这个对象在内存中消失?
1. class Single{
2.
3. private static Single s =null;
4.
5. private Single(){}
6.
7. public static Single getInstance(){
8. if (s==null)
return new Single();
9. }
10. }