java - Check in compile time if someClass.class is derived from a anotherClass.class? -
This is a newbie question, in Java, if I have some class. If the class is possible at compile time, then another class. In class or run-time
In the code:
anotherClass. Class.isAssignableFrom (someClass.class); If you also want to check that the other class is a real square (and not the interface), then add it to the call:
! AnotherClass Class.isInterface () & amp; Amp; & Amp; Second class Class. EssentialFamFom (some class class); Example:
System.out.println (number.clash.esignableForm (integer.clash)); // true Note that for example will not work for you because you do not have just examples.
The class or interface represented by this class object is either the same, or is a superclass or superfinfo, class or interface The specified class is represented by the parameter. If it is true then if it gives; Otherwise it incorrectly if this class object represents a primitive type, then this method returns true if the specified class parameter is actually a class object; Otherwise it returns false.
Comments
Post a Comment