when we overide the equals method in a class for a given object then we use getClass to check the class type of the given object.
InstanceOF is also a option here but I know that instanceOf is a bad/inefficient and poor programming as I had read it somewhere.
Can any one justify why instanceOf is inefficient then getClass. Also would like to know details of InstanceOf() Vs getClass()
Joined: Oct 13, 2005
Do a google search for "Angelika Langer Java equals method" or find the appropriate chapter in Joshua Bloch's Effective Java, 1st edition or 2nd edition. Those sources both explain the difference.
And no capital letters in instanceof please.
For instanceOf() (presumably not InstanceOf()) you should look in the Java API documentation (I don't have a link to hand just at the moment, sorry) then INDEX then I, and you can find where that method comes from.