Skip to content

Instantly share code, notes, and snippets.

@TonnyXu
Created March 1, 2010 07:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TonnyXu/318153 to your computer and use it in GitHub Desktop.
Save TonnyXu/318153 to your computer and use it in GitHub Desktop.
public final class Singleton {
private static final Singleton INSTANCE = new Singleton();
private Singleton(){
// Do nothing, make sure user can not create object directly
if (null != INSTANCE){
throw new IllegalArgumentException("Already instantiated.");
}
}
public static final Singleton getInstance(){
return INSTANCE;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment