singleton模式的两种方法
方法一:
public enum E2 {INSTANCE;public void print(){System.out.println("singleton test");}public static void main(String []args){E2 a=E2.INSTANCE;E2 b=E2.INSTANCE;System.out.print(a.equals(b)?true:false);}}
?