java对象实现单例三部曲
package com.zr.demo01;
/**
* 对象实现单例
* @author ZR
* 步骤:
*1.构造方法私有化
*2.提供私有静态属性
*3.提供get方法获取对象
*/
public class Twelfth {
//2.提供私有静态属性
private static final Twelfth TWELFTH=new Twelfth();
//1.构造方法私有化
private Twelfth() {
super();
}
//3.提供get方法获取对象
public static Twelfth getTwelfth() {
return TWELFTH;
}
}