Last active
September 29, 2019 18:40
-
-
Save IamLizu/30713623061669f8483139f3e52790bf 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
public class main { | |
public static void main(String[] args) { | |
System.out.println("Demonstrates Singleton class. Output of the two print statement bellow will be same,"); | |
System.out.println("because the class returned the cached instance of the second call."); | |
// Initializing one instance of the singleton class | |
Singleton one = Singleton.getInstance("One"); | |
// Inilializing another instance of singleton class | |
Singleton two = Singleton.getInstance("Two"); | |
System.out.println(one.text); | |
System.out.println(two.text); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment