byte [ ] hehe = { 4 , 5 , 6 }if (hehe instanceof char[]) {
}这样编译会出错:inconvertible types; found:byte[] required char [ ]char[ ] hehe = { 4 , 5 , 6 }if (hehe instanceof char[]) {}这样就不会出错请问是为什么呢?还有就是在此声明的数组又不是对象,那怎么还能使用instanceof运算符呢?
}这样编译会出错:inconvertible types; found:byte[] required char [ ]char[ ] hehe = { 4 , 5 , 6 }if (hehe instanceof char[]) {}这样就不会出错请问是为什么呢?还有就是在此声明的数组又不是对象,那怎么还能使用instanceof运算符呢?
hehe instanceof char[],这样的话你的这个肯定不对了.
而数组也是对象呀.当然可以用instanceof.
下面是我的理解:
比如: a instance new B();这里a 和B要么必须有联系.即继承关系.要么,先将a向上转型为Object.