接口的实现、继承等

 package test.interfacedemo;
import test.interfacedemo.Inter; public class InterfaceDemo {
public static void main(String[] args){
Inter o1 = new Foo(); //Foo实现接口Inter,类同于 向上造型
//通过变量o1可以调用接口Inter中定义的方法和常量
System.out.println(Inter.PI); Inter3 t = new Boo(); //Boo实现接口Inter3
t.a();
t.c();
}
}
 package test.interfacedemo;

 public interface Inter{  //接口定义
public static final double PI = 3.14;
int NUM = 5;
public abstract void show();
void say(); //省略public abstract
} class Foo implements Inter{
public void show(){}
public void say(){}
} interface Inter1{
public abstract void a();
}
interface Inter2{
public abstract void b();
}
interface Inter3 extends Inter1{
public abstract void c();
} abstract class Aoo{
void d(){}
abstract void e();
}
class Boo implements Inter3{
void m(){}
public void a(){
System.out.println("a");
}
public void c(){
System.out.println("c");
}
}
class Coo implements Inter1,Inter2{
public void a(){}
public void b(){}
}
class Doo extends Aoo implements Inter1,Inter2{
void e(){}
public void a(){}
public void b(){}
}
05-12 18:09