Skip to content

Instantly share code, notes, and snippets.

@vitorvezani
Created March 28, 2016 18:52
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 vitorvezani/66a38b511b2dfaac5233 to your computer and use it in GitHub Desktop.
Save vitorvezani/66a38b511b2dfaac5233 to your computer and use it in GitHub Desktop.
Singleton Java
public final class Singleton {
private static final Singleton INSTANCE = new Singleton();
private Singleton() {
if (INSTANCE != null) {
throw new IllegalStateException("Already instantiated");
}
}
public static Singleton getInstance() {
return INSTANCE;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment