何时是“obj instanceof Object” Java中的错误? [英] When is "obj instanceof Object" false in Java?
本文介绍了何时是“obj instanceof Object” Java中的错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
考虑
Object obj = ....;
System.out.println(obj instanceof Object);
obj应该是什么,以便答案是 false
( null
以外的任何其他选项)
What should obj be so that the answer is false
(Any other option other than null
)
推荐答案
一切都在扩展对象,所以你总会在这里得到真实(除非obj为null)。
Everything extends Object, so you will always get true here (unless obj is null).
这篇关于何时是“obj instanceof Object” Java中的错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文