參考:https://www.jianshu.com/p/ceb5ec8f1174spa
https://www.jianshu.com/p/fa15f63d399a3d
用一個靜態方法來對外提供自身實例的方法,即爲咱們所說的靜態工廠方法(Static factory method)
code
//私有化構造方法 private Student() {}; private static volatile Student student; //靜態工廠方法 public static Student getStudentInstance() { return new Student(); }
如:blog