instanceof: incompatible conditional operand types A and B

本文探讨了Eclipse环境中出现的“不兼容条件操作数类型”错误,特别是当缺失import语句时如何引发这一问题。此外,还讨论了instanceof关键字的基本用法及类型检查原则。

Some Guy: A related issue that I have come across recently (and which led me to this page, before I figured out what was going on) is that the Eclipse environment can report "Incompatible conditional operand types" in an 'instanceof' expression erroneously due to a missing 'import' statement for the type on the right of the 'instanceof'. I spent a while trying to figure out how the types in question could possibly be incompatible before figuring out that a missing import was causing the whole problem. Hopefully this information saves somebody some time.

 

在同一个类加载器加载的前提下,使用其生成的对象,去比较才有意义。不同的类加载器加载的类生成对象,互相instanceof返回false。

 

instanceof keyword is a binary operator used to test if an object (instance) is a subtype of a given Type.

 

And,


dog instanceof Cat // does not even compile!

This is because Dog is neither a subtype nor a supertype of Cat, and it also does not implement it.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值