Created
January 12, 2022 04:33
-
-
Save HydroCarbon/f7d5bd5d237005a1f423e7ed72a8469f to your computer and use it in GitHub Desktop.
#Java #Singleton
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Singleton { | |
| private static class SingletonHolder { | |
| private static final Singleton INSTANCE = new Singleton(); | |
| } | |
| private Singleton (){} | |
| public static final Singleton getInstance() { | |
| return SingletonHolder.INSTANCE; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment