반응형
package interface_inheritance;

public interface Animal {
	void species();
	void sex();
}
package interface_inheritance;

public interface Human {
	void name();
	void age();
}
package interface_inheritance;

public class Integreated implements Animal, Human{
	String name;
	int age;
	String sex;
	String species;
	
	public Integreated(String name, int age , String sex , String species) {
		this.name = name;
		this.age = age;
		this.sex = sex;
		this.species = species;
	}

	@Override
	public void species() {
		System.out.println("이 동물은 " + this.species);
	}

	@Override
	public void sex() {
		System.out.println("성별은 " + this.sex);
		
	}

	@Override
	public void name() {
		System.out.println("이름은 " + this.name);
	}

	@Override
	public void age() {
		System.out.println("나이는 " + this.age);
	}
}
package interface_inheritance;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Integreated it = new Integreated("king",25,"Lion","수컷");
		
		it.age();
		it.name();
		it.sex();
		it.species();
	}

}

 

 

public class Integreated implements Animal, Human 이런식으로 다중으로 interface를 상속받을 수 있습니다.

 

public class 클래스명 implements 인터페이스명, 인터페이스명

반응형