유일한 인스턴스를 만들기 위한 디자인 패턴
유일한 인스턴스를 만들기 위한 디자인 패턴
public class dailyCode {
public static class Singleton{
private static Singleton sSingle = new Singleton();
private Singleton(){}
private String notification = "This is Singleton Design Pattern!";
public static Singleton getInstance(){
return sSingle;
}
public String getNotification(){
return notification;
}
}
public static void main(String[] args){
System.out.println(Singleton.getInstance().getNotification());
Singleton tester = Singleton.getInstance();
System.out.println(tester.getNotification());
}
}