![Java Head First 多态 - darrell - DARRELL的博客](http://img0.ph.126.net/dzXfN0y8fcDazFJjUCWAnA==/6631866011142552885.png)
![Java Head First 多态 - darrell - DARRELL的博客](http://img0.ph.126.net/eRSWSII1IqoSf19lqdpXhQ==/6631992454979734383.png)
package com.cwcec.tag; class Fruit { } class Apple extends Fruit{} class Animal { public Fruit eat(Fruit fruit) { System.out.println("Animal eat..."); return fruit; } } class Dog extends Animal { public Fruit eat(Apple apple) { System.out.println("Dog eat..."); return apple; } } public class Single { public static void main(String[] args) { Fruit fruit = new Fruit(); Apple apple = new Apple(); Animal animal = new Dog(); animal.eat(apple); } }