That's easy. Suppose you've got some objects stored in a collection, like a Vector or a List of some sort. You might want to check to see if an individual object belongs to a particular class. The instanceof operator is used in this case.
For example:-
if (obj instanceof MyClass)
{
MyClass.doSomething();
}
else
{
// handle object differently .......
}
www.referjava.com
No comments:
Post a Comment