7.4.2021 |


The Singleton pattern describes the practice of restricting the instantiation of a class to one "single" instance. This is useful when exactly one object is needed to coordinate actions across the system.

public class Singleton {
  private static Singleton instance;
  private Singleton () {}

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

Zur Übersicht

Mehr vom DevSquad...

Sven Röttering

Flux pattern

Sven Röttering

Chain of responsibility