Skip to content

Instantly share code, notes, and snippets.

@up1
Created October 22, 2015 06:44
Show Gist options
  • Save up1/e4fa3f4f655d890743b2 to your computer and use it in GitHub Desktop.
Save up1/e4fa3f4f655d890743b2 to your computer and use it in GitHub Desktop.
Singleton pattern
public class X {
private static X instance = null;
private X() {}
public static X instance() {
if (instance == null)
instance = new X();
return instance;
}
// more methods...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment