Skip to content

Instantly share code, notes, and snippets.

@messi18
Created July 20, 2012 07:19
Show Gist options
  • Save messi18/3149230 to your computer and use it in GitHub Desktop.
Save messi18/3149230 to your computer and use it in GitHub Desktop.
Initialization On Demand Holder idiom
class Something {
private static class LazySomethingHolder {
public static Something something = new Something();
}
// this private constructor is necessary
private Something(){}
public static Something getInstance() {
return LazySomethingHolder.something;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment