Here's a typical use of instanceof that's problematic.If this is an open-ended hierarchy, then as more classes extend A, you'll have to find the code like method f throughout your program and add more cases. A better solution in this case would be if there were a polymorphic method doF() that you could invoke:This doesn't mean that you should never use instanceof. There are places where it's unavoidable.
There are times when you just cannot avoid using instanceof, like when you override Object.equals or Comparable.compareTo. Sometimes the abstraction and contract just won't let you be specific when taking a parameter.
Henrique Sousa<br />SCJP 1.4<br /> <br />All men die, not all men really live - Braveheart, 1995