<source instance> instanceOf <target instance>
source instance is usually a super class type
target instance is usually a sub classBTW, you have to read English Book in order to be a good developer.
source instance is usually a super class type
target instance is usually a sub classBTW, you have to read English Book in order to be a good developer.
为了在程序中支持Runtime Type Identify(运行时类型鉴定)和
动态生成对象,就必须能够判别一个对象的类型,判别它是哪个类的
一个实例。在这里,instanceof 就是完成这个功能的了。
如果不用instanceof做测试,你就不知道它属于继承体系中的哪一个
分支,当然就有可能会有类型转换失败的危险了。