接口与具体的实现类之间也存在多态
package com.aff.inter; public class TestInterface { //接口与具体的实现类之间也存在多态 public static void main(String[] args) { Fang f = new Fang(); TestInterface.test1(f); TestInterface.test2(f); TestInterface.test3(f); } public static void test1(Run r) {//Run r = new Fang(); r.run(); } public static void test2(Swimmer s) {//Swimmer s = new Fang(); s.swim(); } public static void test3(Fly f) {//Fly f = new Fang(); f.flying(); } } interface Run { public abstract void run(); } interface Swimmer { void swim(); } interface Fly { void flying(); } class Fang implements Run, Swimmer, Fly { @Override public void flying() { System.out.println("可以飞的更高"); } @Override public void swim() { System.out.println("可以游得更远"); } @Override public void run() { System.out.println("可以跑得更快"); } }