I'm relatively new to
java and am studying for the
SCJP. I haven't seen the instanceof operator in use in any code that I've looked at so far, but what's the point?
If you can only use it to
test objects against class types that are in the same class hierarchy, won't it always return true if the variable on the left refers to an object that is in the class hierarchy (or false if null) and always not compile if the object refered to is not? Of course, it will return false if the variable is null, but in that case why not just test for null?
Thanx,
DMad