Skip to content

Instantly share code, notes, and snippets.

@surajdubey
Created April 14, 2018 04:17
Show Gist options
  • Select an option

  • Save surajdubey/881e8c479e699bd18c84a868bd6c77ed to your computer and use it in GitHub Desktop.

Select an option

Save surajdubey/881e8c479e699bd18c84a868bd6c77ed to your computer and use it in GitHub Desktop.
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