// 껍데기 + 알맹이 - 변경에 불리, 유연 X
class B{
public void method(){
System.out.println("methodB");
}
}
위 코드를 아래와 같이 분리
// 껍데기(선언)
interface I {
public void method();
}
// 알맹이(구현)
class B implements I {
public void method(){
System.out.println("methodInB");
}
}
// A는 B와 관계 없음
class A {
public void methodA(I i){
i.methodB();
}
}
interface I { void methodB(); }
class B {
public void methodB() {
System.out.println("methodB()");
}
}
class C {
public void methodB() {
System.out.println("methodB() in C");
}
}