Created
June 2, 2020 12:47
-
-
Save bhawna94/c3c4a860f2579e446846b0a444972f54 to your computer and use it in GitHub Desktop.
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
class Singleton { | |
//static field | |
private static Singleton object; | |
//private Construtor | |
private Singleton() {} | |
//static method | |
public static synchronized Singleton getInstance() | |
{ | |
if (object == null) | |
object = new Singleton(); | |
return object; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment