Assume the following structure of an object:
class Super {} class SubA extends Super {} class SubB extends Super {}
I want to have a variable that will hold a class object for any of my subclasses. I feel this should do it:
Class<Super> classObj;
Then I want to be able to do something like this:
classObj = SubA.class;
or
classObj = SubB.class;
This does not work. I get the following error:
Type mismatch: cannot convert from Class<SubA> to Class<Super>
Any ideas why? What do I need to fix?
source share