7.4.2021 |

Singleton

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
Jan Sauer

Mehr vom Devsquad...

Sven Röttering

Flux pattern

Sven Röttering

Chain of responsibility

Hallo, ich bin Jörg Herbst!

Ich bin der CEO von newcubator und freue mich über jede Nachricht!

* Pflichtfeld