Singleton

Singleton is a creational design pattern that ensures a class has only one instance and provides a global point of access to that instance.

Example:

public class Singleton {
    private static Singleton instance;

    private Singleton() {
        // Private constructor to prevent instantiation
    }

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

Usage:

Singleton singleton = Singleton.getInstance();