
garbage collector

싱글톤
- 패턴 객체를 메모리에 단 한개 입력 가능
class President{
static President instance = new President();
private President(){
}
}
public class SingleTonEx01 {
public static void main(String[] args) {
President p1 = President.instance;
System.out.println(p1.hashCode());
President p2 = President.instance;
System.out.println(p2.hashCode());
}
}
Share article