싱글톤 패턴(singtonPanttern)

김재원·2021년 12월 19일
0

자바

목록 보기
27/41

싱글톤 패턴(singtonPanttern)

객체가 단 1개만 존재할 때 외부에서 new를 하지 못하게
막아주고 클래스 내부에서 new를 한 후 외부에서 선언이 아닌
사용만 해준다.

IronMan i = new IronMan();
//싱글턴패턴 getInstance();
IronMan i =IronMan.getInstance();
IronMan.fight();
i.walk();

profile
우당탕탕 주니어 디벨로퍼

0개의 댓글