Skip to content

Instantly share code, notes, and snippets.

@adewale
Created November 9, 2013 19:39
Show Gist options
  • Save adewale/7388992 to your computer and use it in GitHub Desktop.
Save adewale/7388992 to your computer and use it in GitHub Desktop.
public class SingletonExample {
private static SingletonExample instance = new SingletonExample();
public static SingletonExample getInstance() {
return instance;
}
private SingletonExample() {
//Make sure they can't create another instance
}
public void doSomething() {
//Whatever this thing actually is supposed to do
System.out.println("Ceci n'est pas une Singleton");
}
public static void main(String[] args){
SingletonExample.getInstance().doSomething();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment