Created
October 22, 2015 06:44
-
-
Save up1/e4fa3f4f655d890743b2 to your computer and use it in GitHub Desktop.
Singleton pattern
This file contains 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
public class X { | |
private static X instance = null; | |
private X() {} | |
public static X instance() { | |
if (instance == null) | |
instance = new X(); | |
return instance; | |
} | |
// more methods... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment