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();
- System.out.println(s.text);
- }
- }
- class Singleton{
- private static Singleton single_instance = null;
- public String text;
- private Singleton() {
- text = "Coś do wypisania.";
- }
- //tworzenie instancji klasy Singleton
- public static Singleton getInstance()
- {
- if (single_instance == null)
- single_instance = new Singleton();
- return single_instance;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement