What is the instanceof operator used for? I\'ve seen stuff like
instanceof
if (source instanceof Button) { //... } else { //... }
Can be used as a shorthand in equality check.
So this code
if(ob != null && this.getClass() == ob.getClass) { }
can be written as
if(ob instanceOf ClassA) { }