프로그래밍에서 구상 클래스란 new 키워드로 객체를 생성할 수 있는 클래스를 말한다.
(추상 클래스의 반대 개념으로, 인스턴스화가 가능한 클래스를 말한다.)
다르게 말하면, 클래스의 모든 메서드를 완벽하게 구현한 클래스라고 할 수 있다.
<aside> 💡
Tip. 구상(Concrete)이란? 추상(Abstract)과 대조적인 단어로 이해하면 쉽다. 추상이 구체적이지 않은 모호한 뜻을 가졌다면, 구상은 구체적이고 명확한 뜻을 가졌다.
</aside>
예를 들어, IronMan 클래스의 모든 메서드는 구현되어 있으므로 구상 클래스라 할 수 있다.
public class IronMan {
public void attack() {
System.out.println("Iron Man, attack!");
}
public void greet() {
System.out.println("I'm Iron Man");
}
public void jabis() {
System.out.println("Hey Jabis");
}
}
구상 클래스답게 new 키워드로 객체를 생성할 수 있다.
IronMan ironMan = new IronMan();
Java의 대표적인 구상 클래스로 ArrayList, LinkedList, HashMap, HashSet 등이 있다.
[디자인 패턴] 구상 클래스(Concrete class)란?
추상클래스 (Abstract Class), 구상클래스 (Concrete Class), 인터페이스 (Interface)