| 구성 요소 | 설명 |
|---|---|
상수 (public static final) | 모든 변수는 자동으로 public static final 로 간주됨 |
추상 메서드 (public abstract) | 메서드는 구현부 없이 선언만 가능함 |
인터페이스 내 모든 메서드와 필드는 명시하지 않아도 public abstract, public static final이 기본
interface Animal {
void sound();
}
class Dog implements Animal {
public void sound() {
System.out.println("멍멍");
}
}
Animal a = new Dog(); // 다형성 적용
a.sound(); // 멍멍 출력
Runnable, Comparable, Serializable 등 able 접미사 많이 사용함extends 가능 → 인터페이스 확장interface A {}
interface B extends A {} // 인터페이스 간 상속