* 사용
static void SingleToneInstanceTest() {
// SingletoneInstance inst = new SingletoneInstance() ; // ERROR as constructor is private
SingletoneInstance inst = SingletoneInstance.newInstance() ;
}
class SingletoneInstance
{
// 단 하나의 객체로만 운영할 때
private static SingletoneInstance single = null ;
private SingletoneInstance() { // make can't instance with new
}
static SingletoneInstance newInstance() {
if (single==null)
return new SingletoneInstance() ;
else
return single ;
}
}
'기타 이슈' 카테고리의 다른 글
Android Studio 에서 alt+Enter / option+Enter 작동하지 않을 때 (0) | 2021.10.06 |
---|---|
builder 디자인 패턴 공부중.. (0) | 2021.05.14 |
Android Studio 단축키 (0) | 2021.03.19 |
블로그 및 프로그램 (0) | 2021.03.19 |