class Birds
{
public void work()
{
System.out.println("总统主要工作");
}
}
class Chickens extends Birds
{
public void work()
{
System.out.println("Chickens主要工作");
}
}
class Main
{
public static void main(String[] args)
{
Birds s = new Chickens();
s.work();
Birds z = new Birds();
z.work();
Birds q = new Birds();
if (q instanceof Chickens)
{
Chickens p = (Chickens) q;
}
}
}
Java 小白 instanceof 判断“鸡是不是鸟” 并阐明根据
最新推荐文章于 2024-05-06 17:27:50 发布