interface Edible
{
public String howToEat();
}
interface Comparable
{
public int comparaeTo(Object o);
}
class Animal
{

}
class Chicken extends Animal implements Edible, Comparable
{
int weight;
public Chicken(int weight)
{
this.weight = weight;
}
public String howToEat()
{
return "Fry it";
}
public int compareTo(Object o)
{
return weight - ((Chicken)o).weight;
}
}
class Tiger extends Animal
{

}
abstract class Fruit implements Edible
{

}
class Apple extends Fruit
{
public String howToEat()
{
return "Make apple cider";
}
}
class Orange extends Fruit
{
public String howToEat()
{
return  "Make orange juice";
}
}
public class TestEdible
{
    public static void main(String[] args)
    {
   Object[] objects = {new Tiger(), new Chicken(), new Apple()};
        for(int i = 0; i < objects.length; i++)
        showObject(objects[i]);
    }
    public static void showObject(Object object)
    {
     if(object instanceof Edible)
     System.out.println(((Edible)object).howToEat());
    }
}
这道 程序有点小错误,但怎么也看不出,麻烦改写下咯,呵呵,谢谢