└── java singleton pattern /java singleton pattern: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | import java.text.*; 4 | import java.math.*; 5 | import java.util.regex.*; 6 | import java.lang.reflect.*; 7 | 8 | 9 | final class Singleton{ 10 | public String str = "Hello I am a singleton! Let me say hello world to you"; 11 | 12 | private static Singleton singleton; 13 | 14 | private Singleton(){ 15 | 16 | } 17 | 18 | public static Singleton getSingleInstance(){ 19 | if(singleton == null) 20 | singleton = new Singleton(); 21 | 22 | return singleton; 23 | } 24 | } 25 | --------------------------------------------------------------------------------