SHARE
TWEET

Untitled

a guest Nov 17th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. public class Main {
  3.  
  4.     public static void main(String[] args) {
  5.         Singleton s = Singleton.getInstance();
  6.         System.out.println(s.text);
  7.  
  8.     }
  9.  
  10. }
  11.  
  12. class Singleton{
  13.  
  14.     private static Singleton single_instance = null;
  15.     public String text;
  16.    
  17.     private Singleton() {
  18.         text = "Coś do wypisania.";
  19.     }
  20.    
  21.     //tworzenie instancji klasy Singleton
  22.     public static Singleton getInstance()
  23.     {
  24.         if (single_instance == null)
  25.             single_instance = new Singleton();
  26.  
  27.         return single_instance;
  28.     }
  29. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top