Java / Object, Class and Package
Difference between instanceof and getClass() method for checking type inside equals.
instanceof operator returns true, even if compared with subclass, for example, Subclass instanceof Superclass is true, but with getClass() its false. By using getClass() you ensure that your equals() implementation doesn't return true if compared with subclass object.
More Related questions...