Welcome

This website is intended to be a code snippet helps website for me and eventually other people.

No special care have been made on formatting, thus do not blame me about the the look and feel of the website.


public class Singleton {
    private static Singleton instance;

    private Singleton() {
        // Private constructor to prevent instantiation from outside the class
    }

    public static Singleton getInstance() {
        if (instance == null) {
            synchronized (Singleton.class) {
                if (instance == null) {
                    instance = new Singleton();
                }
            }
        }
        return instance;
    }
}