reflection - Java - How Can I Check If A Class Is Inheriting From Some Class Or Interface? -


i need check:

public static boolean check(class<?> c, class<?> d) {     if (/* c inherits d */)         return true;     else         return false; } 

how can ?

and possible without c.newinstance() ?


title wrong @ first time. it's correct.

use isassignablefrom

if(d.isassignablefrom(c)){     // d superclass of c     // in other words, c inherits d } 

determines if class or interface represented class object either same as, or superclass or superinterface of, class or interface represented specified class parameter. returns true if so; otherwise returns false. if class object represents primitive type, method returns true if specified class parameter class object; otherwise returns false.

source


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -