java - Get all classnames that extend a specific class -
in java project, need variable each class extends class. problem here don't know name of these classes. let's classtree looks this:
package - myproject - baseclass - class 1 extends baseclass - class 2 extends baseclass - class 3 extends baseclass - class 4 - class 5
now each class extends baseclass has variable basevariable
, , need value in myproject
. there way list of classes extend baseclass, can access basevariable value?
thanks in advance
you use reflections:
set<class<? extends baseclass>> subclasses = reflections.getsubtypesof(baseclass.class);
Comments
Post a Comment