Can anyone outline the use of the keyword "instanceof".
I mean, when do we use it etc..

Couple of examples would make it clearer i guess...

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/op2.html

Read the section on instanceof. One good use of instanceof is in the equals() method that is inherited from the Object class. Since the method is defined as taking a type Object as a parameter, you need to check that it is of the correct type before casting it to that type - otherwise you would get an error. Read this article for info about how to implement the equals() method if you never have before. In their implementation of the equals method, you'll see that they use instanceof.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.