I understand that Singelton helps to instantiate only one class AT A TIME. I try to learn how to Design for Singleton function in java.  I want to know it better to understand Kernel. So I try to do this following, but I like to know if it's the only way to come up with private constructor.public class Singleton {    private static Singleton instance = null;    private Singleton() {   }    public static synchronized Singleton getInstance() {        if (instance == null) {                    instance = new Singleton ();        }        return instance;    }}
Simple Design for Singleton function in java for Kernel
java;singleton
yes, to create a Singleton class, you have to use the private constructor as it is the only way to prevent another class from creating an instance of your class.  public class Singleton {private static Singleton instance = null;private Singleton() {   }public static synchronized Singleton getInstance() {    if (instance == null) {                instance = new Singleton ();    }    return instance;}}