的instanceof [英] instanceof

查看:80
本文介绍了的instanceof的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以为一个'if'设置多个实例代码吗?例如.....

Can I have many instanceof code for one ''if'' ? for example.....

展开 | 选择 | Wrap | 行号

推荐答案

不,你不能因为结果instanceof运算符是一个布尔值,即

对象要么是(true),要么不是某个类/接口的实例。


例如true instanceof Object 真实在哪里并不合理是另一个instanceof的结果


当然你可以这样做,例如:
No you can''t because the result of the instanceof operator is a boolean, i.e.
an object either is (true) or isn''t an instance of a certain class/interface.

e.g. "true instanceof Object" doesn''t make sense where "true" is the result
of another "instanceof" sub-expression.

Of course you could do this, e.g.:
展开 | 选择 | Wrap | 行号



不,你不能因为instanceof运算符的结果是布尔值,即

对象是(true)还是不是实例某个班级/界面。


例如true instanceof Object 真实在哪里并不合理是另一个instanceof的结果


当然你可以这样做,例如:
No you can''t because the result of the instanceof operator is a boolean, i.e.
an object either is (true) or isn''t an instance of a certain class/interface.

e.g. "true instanceof Object" doesn''t make sense where "true" is the result
of another "instanceof" sub-expression.

Of course you could do this, e.g.:
展开 | 选择 | Wrap | 行号



我明白了。实际上我的目标是处理对象的属性 - checkMe。然后我想对象是A和instanceof B的内容。然后我应该写
I see. Actually my aim here is to process attributes of object - checkMe. Then I wanna the object is intanceof A and instanceof B. Then I should write
展开 | 选择 | Wrap | 行号


这篇关于的instanceof的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆