클래스(Class) vs 객체(object) vs 인스턴스(instance)

CODEDRAGON Development/Java

반응형


 

클래스 vs 객체 vs 인스턴스

객체(Object) 컨스트럭터(Constructor) 통해 이니셜라이즈(Initialize)하여 생성합니다.

 

Java

AppleSeller seller = new AppleSeller();

Kotlin

seller : AppleSeller = AppleSeller()

Python

seller = AppleSeller()

 

구분

설명

클래스(Class)

·         AppleSeller 클래스입니다.

·         객체를 만드는 설계도

객체(Object)

·         seller 객체입니다.

·         클래스로부터 만들어지는 각각의 객체를 의미합니다.

 

인스턴스(Instance)

·         seller이라는 객체는 AppleSeller클래스의 인스턴스입니다.

·         객체를 클래스의 인스턴스(Instance)라고도 합니다.

·         인스턴스란 메모리에 할당된 객체를 의미합니다.

·         인스턴스라는 말은 특정 객체(seller) 어떤 클래스(AppleSeller) 객체인지를 관계 위주로 표현할 사용됩니다.

표현

·         "seller 인스턴스이다" 보다는 "seller 객체이다"라는 표현이 어울리며, "seller AppleSeller 객체이다" 보다는 "seller AppleSeller 인스턴스이다" 라는 표현이 훨씬 정확한 표현입니다. 하지만 혼용되어져서 사용되기도 합니다.

 

객체(Object) 인스턴스(Instance) 객체참조 참조변수

 


반응형