Singleton

Zhukov Maxim edited this page Jul 26, 2017 · 2 revisions

IMPLEMENTING THE SINGLETON DESIGN PATTERN WITH @SINGLETON

To implement the Singleton Design Pattern in Java, you have to write boilerplate code like the one shown in the red box below. If you would rather not do that every time, you can just add the @Singleton class annotation to your class declaration. This is shown in the green box below. Consult the Javadoc to find out more about the @Singleton annotation, and of other GoF design patterns supported by dp4j.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.