Web/소스코드
[자바] interface에 관한 간단한 이해 코드
jinsiri
2019. 6. 14. 19:31
class Parent{
void hello(){"안녕1"}
}
interface Parent{
void hello();
}
class Child implements Parent{//extends Parent{
void hello(){"안녕2"}
}
Parent p = new Parent();
p.hello();
Parent p = new Child();
p.hello();
// 안녕2가 출력된다. 왜냐? Child가 parent를 implements하고 있으니까
반응형