用枚举回实现SINGLETON模式

用枚举来实现SINGLETON模式public enum Singleton { INSTANCE public static Singleton getInstance() {r

用枚举来实现SINGLETON模式

public enum Singleton { INSTANCE; public static Singleton getInstance() {       return INSTANCE;     }  public void sayHello(){  System.out.println("hello world!"); } public static void main(String[] args){  Singleton.INSTANCE.sayHello(); }}