How do I know if a class inherits from another class?
satya - Friday, September 29, 2006 1:54:54 PM
Try something like this
Class baseClass; Class derivedClass; if (baseClass.isAssignableFrom(derivedClass)) { System.out.println( "derviedClass is derived from baseClass" + "or assignable a bit more precisely"); }
satya - Monday, October 02, 2006 2:23:08 PM
How can I instantiate an object from its classname
private Object constructObject(String classname) throws ClassNotFoundException ,InstantiationException ,IllegalAccessException { Class oClass = Class.forName(classname); return oClass.newInstance(); }