I know that I can find out an object's classname with
getClass().getName()
However, I do not know how to find out weather the object extends a
certain Class.
Any help is very much appreciated.
Chris Uppal - 24 Nov 2005 11:20 GMT
> I know that I can find out an object's classname with
> getClass().getName()
>
> However, I do not know how to find out weather the object extends a
> certain Class.
Look up the keyword/operator:
instanceof
(with that exact case and spelling).
-- chris
J. Verdrengh - 24 Nov 2005 11:20 GMT
> However, I do not know how to find out weather the object extends a
> certain Class.
You're expressing yourself incorrectly but I suppose you want this:
if(object instanceof Class){...}
> Any help is very much appreciated.
Robert Klemme - 24 Nov 2005 12:34 GMT
>> However, I do not know how to find out weather the object extends a
>> certain Class.
> You're expressing yourself incorrectly but I suppose you want this:
> if(object instanceof Class){...}
For dynamic solutions see
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Class.html#isInstance(java.lan
g.Object)
robert
Roedy Green - 24 Nov 2005 12:35 GMT
>However, I do not know how to find out weather the object extends a
>certain Class.
see instanceof operator

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.