Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Public constructor singleton
- */
- public class Singleton {
- private static Singleton instance = null;
- public static Singleton getInstance() {
- if (null == instance) {
- instance = new Singleton();
- }
- return instance;
- }
- public Singleton() {
- if (instance != null) {
- throw new RuntimeException("Sorry this is a singleton");
- }
- instance = this;
- }
- }
Add Comment
Please, Sign In to add comment