main.java

来自「java netbeans 学习程序合集」· Java 代码 · 共 70 行

JAVA
70
字号
/*
 * Main.java
 *
 * Created on 2007年7月27日, 下午9:08
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package 接口;

/**
 *
 * @author Administrator
 */
public class Main {
    
    /** Creates a new instance of Main */
    public Main() {
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
       Fish f=new Fish();
  f.run();
  f.breath();
  Person1 s=new Person1();
  s.run();
  s.breath();
  s.work(); 
        // TODO code application logic here
    }
    
}
interface Runner
{
  void run();
}
interface Animal extends Runner
{
  void breath();
}
class Fish implements Animal
{
  public void run()
  {
   System.out.println("fish is swimming!");
  }
  public void breath()
  {
   System.out.println("fish is breathing in water!");
  }
}
class Person1 implements Animal
{
  public void run()
  {
   System.out.println("Person is running!");
  }
  public void breath()
  {
   System.out.println("Person is breathing on land!");
  }
  public void work()
  {
   System.out.println("Person can work!");
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?