我所期望的是‘当potentialByteArray instanceof byte[]是一个byte[]的实例时,potentialByteArray会返回true,但这似乎不会发生--由于某种原因,它总是错误的!
我有一个条件,如下所示:
if (!(potentialByteArray instanceof byte[])) { /* ... process ... */ }
else {
log.warn("--- can only encode 'byte[]' message data (got {})", msg.getClass().getSimpleName());
/* ... handle error gracefully ... */
}...and输出的内容如下:
--- can only encode 'byte[]' message data (got byte[])这意味着这个对象实际上是一个byte[],但在某种程度上不是一个instanceof byte[]。所以..。这对Byte[]有用吗?这到底是怎么回事,为什么不像我预期的那样起作用呢?
什么是合适的成语来代替这里使用?
发布于 2011-08-30 17:23:12
看起来你有一个不需要的! (不是)
if (!(potentialByteArray instanceof byte[])) {...}应该是
if (potentialByteArray instanceof byte[]) {...}https://stackoverflow.com/questions/7247198
复制相似问题