How do I test if one class is an 'instance of' another class when both of the operands are, in fact, classes? I can check whether an object is an instance of a class, but in this case I have two classes -- dynamic at run time -- and I want to see if one implements the other. Thanks!
william kane
Ranch Hand
Joined: Nov 21, 2000
Posts: 260
posted
0
use the isAssignableFrom(Class cls) of the Class object to check the same. hope u gottit
Help me!Help you!!!
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
posted
0
Notice that assignableFrom has the *reverse logic* of instanceof! That is: (a instanceof B) <==> (B.class.assignableFrom(a.getClass())) [ May 20, 2002: Message edited by: Ilja Preuss ]
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus