How to know a class of an object?
For instance you have a collection of object in an list object and you want to do some logic base on the object class. This can easily be done using the instanceof operator. The operator returns true if an object is an instance of a class, if not it will return false.
The instanceof method is most likely used when implementing a equals(Object o) method of an object.