// Singleton Pattern Used in Java Stand Library
class AmericaPresident {
private AmericaPresident() { }
private static AmericaPresident thePresident;
public static AmericaPresident getPresident(){
if(thePresident == null)
thePresident = new AmericaPresident();
return thePresident;
}
}
public class AmericaPresidentTest {
public static void main(String[] args) {
AmericaPresident a = AmericaPresident.getPresident();
}
}
댓글 없음:
댓글 쓰기