Created
August 5, 2013 23:04
-
-
Save cgoodmac/6160452 to your computer and use it in GitHub Desktop.
Singletons in java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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