Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main
- {
- public static void main(String[] args)
- {
- Singleton s = Singleton.getInstance();
- }
- }
- final class Singleton {
- private static Singleton instance = null;
- private Singleton() {}
- public static synchronized Singleton getInstance() {
- if (instance == null) instance = new Singleton();
- return instance;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement