Created
April 14, 2018 04:17
-
-
Save surajdubey/881e8c479e699bd18c84a868bd6c77ed to your computer and use it in GitHub Desktop.
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
| class LazySingleton { | |
| // singleton instance | |
| private static LazySingleton lazySingleton = null; | |
| /** | |
| * private constructor so that other classes can't | |
| * instantiate it through constructor | |
| */ | |
| private LazySingleton() { | |
| // all initialization steps go here | |
| } | |
| public static LazySingleton getInstance() { | |
| if(lazySingleton == null) { | |
| lazySingleton = new LazySingleton(); | |
| } | |
| return lazySingleton; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment