PatternSingleton: Initial commit

This commit is contained in:
2022-05-07 23:54:49 +02:00
parent 0fe0a70258
commit 87e8cd1e09
4 changed files with 51 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
public class Singleton {
//create an object of SingleObject
private static Singleton instance = new Singleton();
//make the constructor private so that this class cannot be
//instantiated
private Singleton(){}
//Get the only object available
public static Singleton getInstance(){
return instance;
}
public void showMessage(){
System.out.println("There can be only One!");
}
}