Guest User

Untitled

a guest
May 27th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. /**
  2. * Public constructor singleton
  3. */
  4. public class Singleton {
  5. private static Singleton instance = null;
  6.  
  7. public static Singleton getInstance() {
  8. if (null == instance) {
  9. instance = new Singleton();
  10. }
  11. return instance;
  12. }
  13.  
  14. public Singleton() {
  15. if (instance != null) {
  16. throw new RuntimeException("Sorry this is a singleton");
  17. }
  18. instance = this;
  19. }
  20. }
Add Comment
Please, Sign In to add comment