
Instanceof Operator determine the type of an object(Class type/ Interface type/Array type).Instanceof Operator verifies whether its first operand is an instance of its second.
Syntax of instanceof
A instanceof B
A must be the name of an object and B must be the name of a class/interface/array type.
An object is considered to be an instance of a class if the object directly or indirectly descends from that class.
As Example:
class X {
}
class Y extends X{
}
X x = new Y();
if (x instanceof X) {
System.out.println("Instance of X");
}
if (x instanceof Y) {
System.out.println("Instance of Y");
}
In the above Example, the Output will be
Instance of X
Instance of Y
When I originally commented I clicked the "Notify me when new comments are added" checkbox and now each time a comment is added I
ReplyDeleteget three emails with the same comment. Is there any way you
can remove people from that service? Thank you!
My website cigarette electronique
Click to see the code!
To insert emoticon you must added at least one space before the code.