Originally posted by meera kanekal:
Yes I did, and I get a compiler error. So the same explanation holds true for String as well. So am I correct in saying that you cannot use "instanceof" test on final classses?
Thanks,
Meera
No. It is not correct. Of course, you can use the instanceof operator with final classes.
The issue here is with the ability to determine the result at compile time, and determined it as false. If, at compile time, the compiler can guarrantee that there is no way that the object is an instance of a particular class or interface, it will report it as a failure at compile time.
And how the compiler makes such a determination is based on the reference type being checked, the type it is checking, and/or whether these types are final or not.
Henry
[ December 07, 2008: Message edited by: Henry Wong ]