Assuming that you have a lot of classes that extends
the class Base
.
class Base{}
class A extends Base[}
class B extends Base{}
class C extends Base{}
What must I write so that when I write a get method, I will get the class that I want?
public Base get(Class <? extends Base> clazz, final String key){
//not important.
}
I want the method to return Objects of class
A
, B
, or C
, depending on the input clazz
.