interface Fightable{
void move(int x, int y);
void attack(Fightable f);
// ㄴ> 인터페이스를 구현한 클래스의 인스턴스만 가능
}
//Fighterble 인터페이스를 구현한 클래스의 인스턴스를 반환
Fightable method(){
Fighter f = new Fighter();
return f; // Fighter객체를 반환(인터페이스를 구현한 객체를 반환)
}
메서드를 호출한 쪽에서는 Fightable과 일치하는 타입의 변수 f에 결과를 저장
Fightable f = method();