Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否有可能在java中得到与instanceof相反的东西?我试过这样的代码:
if( example !instanceof blarg)....
但它不会让我把!任何地方都没有错误,请帮助。
你必须否定整个事情:
if(!(example instanceof blarg))
你也可以这样写:
if(example instanceof blarg == false)
作为替代使用isInstance方法:
isInstance
if (!example.class.isInstance(blarg)) { // your code here }