java基础之extends与implement

来源:互联网 发布:网络实验室耗材清单 编辑:程序博客网 时间:2024/05/16 15:32

直接上代码,举例示意extends与implement的区别

Java extends和implements区别



//define a runner interface
 public interface Runner
 {
    int ID = 1;
    void run();
 }
 //define a interface Animal extends Runner
 interface Animal extends Runner
 {
    void breathe();
 }
 
 //define fish class realization the interface of Animal run() && breathe
 class Fish implements Animal
 {
  public void run()
  {
    System.out.printIn("fish is swimming");
  }
   public void breath()
   {
     System.out.printIn("fish is bubbing");
   }
 }
 
0 0