In my Java book, I just read that the following line is not legal:
if (x instanceof Object )
The reason given is that "the array (x) may be of a primitive type, in which case the test will fail". And that's the extent of the explanation - which left me confused.
So I wrote a little test for myself, where x is an int array. When i tried to compile code with that illegal line in it I got a compiler error "Inconvertible types".
Does the compiler test that 1) both arguments are arrays (test passes) 2) element types of both arrays are the same - but it uses arithmetic promotion to promote the int type up to an Object type before doing so (which results in the "Inconvertible types" error)?
Am I on the right track or waaaay off..?
Any help would be really appreciated Thanks! Juliet