1.使用单元素的枚举类型

 public enum Singleton implements Serializable {

     INSTANCE;

     private String field;

     public String getField() {
return field;
} public void setField(String field) {
this.field = field;
} public void leaveTheBuilding(){
System.out.println("Singleton"); }
}
04-23 00:22