28.4.2021 |

Singleton in with enum in Java

We have already presented the (standard) singleton pattern, using Java. Using modern Java there is a more lightweight thread safe way creating singletons by using an enum.

public enum Highlander {
    MAC_LEOD;

    public String talk(String message) {
        return message;
    }
}
Zur Übersicht

Mehr vom DevSquad...

Jörg Herbst

How to cypress for testing

Jörg Herbst

10 Rules of Software Engineering