Last active
November 22, 2020 17:36
-
-
Save anjanashankar9/48ee247116e1c692b7b9376fb558b1be to your computer and use it in GitHub Desktop.
Defining a singleton class
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 { | |
private static Singleton instance = null; | |
private Singleton(){} | |
public static Singleton getInstance(){ | |
if (instance == null) { | |
instance = new Singleton(); | |
} | |
return instance; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment