자바 키워드 implements

1 개요[ | ]

implements
임플리먼츠, 임플러먼츠 [ímpləmənts]

2 예시 1[ | ]

interface Animal {
  public void animalSound();
}
class Duck implements Animal {
    public void animalSound() {
        System.out.println("Quack");
    }
}
public class App {
    public static void main(String[] args) {
        Animal a = new Duck();
        a.animalSound();
    }
}

3 예시 2[ | ]

interface Animal {
    public void animalSound();
    public void sleep();
}
class Dog implements Animal {
    public void animalSound() {
        System.out.println("bark");
    }
    public void sleep() {
        System.out.println("zzz");
    }
}
public class App {
    public static void main(String args[]) {
        Animal d = new Dog();
        d.animalSound();
        d.sleep();
    }
}

4 같이 보기[ | ]

5 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}