Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package singleton;
- class Printer {
- private static Printer instance;
- private Printer() {}
- public static Printer getInstance() {
- if (instance == null) {
- instance = new Printer();
- }
- return instance;
- }
- public void connect() {
- System.out.println("Do something here");
- }
- }
- public class Singleton {
- public static void main(String[] args) {
- Printer.getInstance().connect();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment