public class Interface { public static void main(String[] args) { System.out.println(Flyable.max_speed); System.out.println(Flyable.min_speed); //类与接口是实现关系 Bullet b = new Bullet(); b.attack(); b.fly(); Flyable f = new Bullet(); f.fly(); } } interface Flyable { public static final int min_speed = 0; public static final int max_speed = 7900; public abstract void fly(); } interface Attack { public abstract void attack(); } class Airplane implements Flyable { public void fly() { System.out.println("Fly"); } } class Bullet implements Attack,Flyable { public void attack() { System.out.println("子弹袭击"); } public void fly() { System.out.println("飞出去击中"); } } interface A { public abstract void A(); } interface B { public abstract void B(); } interface C extends A,B //接口可以多继承 { } class D implements C { public void A() { } public void B() { } }
public class Interface
{
public static void main(String[] args)
{
System.out.println(Flyable.max_speed);
System.out.println(Flyable.min_speed);
//类与接口是实现关系
Bullet b = new Bullet();
b.attack();
b.fly();
Flyable f = new Bullet();
f.fly();
}
}interface Flyable
{
public static final int min_speed = 0;
public static final int max_speed = 7900;public abstract void fly();
}interface Attack
{
public abstract void attack();
}class Airplane implements Flyable
{
public void fly()
{
System.out.println("Fly");
}
}class Bullet implements Attack,Flyable
{
public void attack()
{
System.out.println("子弹袭击");
}public void fly()
{
System.out.println("飞出去击中");
}
}interface A
{
public abstract void A();
}interface B
{
public abstract void B();
}interface C extends A,B
//接口可以多继承
{}
class D implements C
{
public void A()
{}
public void B()
{}
}
JAVA接口的基本测试------JAVA
于 2023-04-24 23:36:12 首次发布