WON.dev
chapter01 : interface 본문
package org.joonzis.ex;
interface Animal{
void move(); // 자동으로 abstract public void move(); 로 처리된다.
void eat(String food);
}
class Dog implements Animal{
@Override
public void move() {
System.out.println("개가 달린다.");
}
@Override
public void eat(String food) {
System.out.println(food + "먹는다.");
}
}
public class Ex01_Interface {
public static void main(String[] args) {
//Animal animal = new Animal();
Animal animal = new Dog();
animal.move();
animal.eat("사료");
}
}
'JAVA > chapter18_interface' 카테고리의 다른 글
Test . interface (0) | 2023.05.30 |
---|---|
chapter03 : interface (0) | 2023.05.30 |
chapter02 : interface (0) | 2023.05.30 |