类TestInterface
public class TestInterface {
public static void main(String[] args) {
Volant v=new Angel();
v.fly();
Honest h=new GoodMan();
h.helpOther();
}
}
接口Volant、Honest
interface Volant{
int FLY_HEIGHT=1000;
void fly();
}
interface Honest{
void helpOther();
}
接口继承
class Angel implements Volant,Honest{
@Override
public void fly() {
System.out.println("Angel.fly()");
}
@Override
public void helpOther() {
System.out.println("Angel.helpOther()");
}
}
class GoodMan implements Honest{
@Override
public void helpOther() {
System.out.println("GoodMan.helpOther()");
}
}
class BirdMan implements Volant{
@Override
public void fly() {
System.out.println("BirdMan.fly()");
}
}