Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. package com.javarush.test.level14.lesson08.bonus03;
  2.  
  3. /**
  4. * Created by User on 23/01/17.
  5. */
  6. class Singleton {
  7. private static Singleton instance; //declare our singleton, private static == can be called ONLY form singleton itself!
  8.  
  9. private Singleton() //constructor does nothing
  10. {
  11. }
  12.  
  13. public static Singleton getInstance() // return our Singleton
  14. {
  15. if (instance == null) instance=new Singleton(); // if no singleton was created - create the first and only one
  16. return instance;
  17.  
  18. }
  19.  
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement