What is InstanceOf keyword in Java [Example Tutorial]

The Java programming language and JVM are full of hidden gems and even though I am using Java for more than a decade I still get surprised by features that I didn't know for quite some time like shutdown hook, covariant method overriding, and JVM option to refresh DNS cache.  The instanceof operator is also one of the rarely known features of Java, It is used to check if an object is the instance of a particular class or not. It returns true if the object is an instance of the class, otherwise, returns false. You might have seen usages of the instanceof keyword in Java while overriding the equals() method. Since for checking equality of two instances, the first step is to verify whether they are the instance of the same object or not, you can use the instanceof operator there.