Skip to content

Instantly share code, notes, and snippets.

@cgoodmac
Created August 5, 2013 23:04
Show Gist options
  • Save cgoodmac/6160452 to your computer and use it in GitHub Desktop.
Save cgoodmac/6160452 to your computer and use it in GitHub Desktop.
Singletons in java
/**
* Created with IntelliJ IDEA.
* User: cgoodmac
* Date: 8/5/13
* Time: 6:49 PM
* To change this template use File | Settings | File Templates.
*/
public class Logger {
private static Logger thisInstance;
private Logger(){
}
public static Logger getInstance(){
if (thisInstance == null ) {
thisInstance = new Logger();
}
return thisInstance;
}
public void log() {
System.out.print("logb");
}
public static void main(String[]args){
Logger.getInstance().log();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment