中国开发网: 论坛: 程序员情感CBD: 贴子 227688
nostalgic: ...
class 动物
{ void cry()
{
}
}
class 狗 extends 动物 {

void cry()
{ System.out.println("汪汪.....");

}
}

class 猫 extends 动物
{ void cry()
{ System.out.println("喵喵.....");
}
}
class Father
{ public static void main(String args[])
{ 动物 dongwu;
if(Math.random()>=0.5)
{
dongwu=new 狗();
dongwu.cry();
}
else
{
dongwu=new 猫();
dongwu.cry();
}
}
}

相关信息:


欢迎光临本社区,您还没有登录,不能发贴子。请在 这里登录