Is there a way to implement something like
List<Class<? implements MyInterface>> ClassList = new ArrayList<Class<? implements MyInterface>>();
my goal is to create a hashmap from that list, where the keys are the toString methods of the class (defined in MyInterface) and the values are the classes itself. The toString method of every object of this class returns the same result. This way I could create Instances of the classes using the map by searching the right strings.
thank you for trying to help, greetings
List<Class<? implements MyInterface>> ClassList = new ArrayList<Class<? implements MyInterface>>();
should be
List<Class<? extends MyInterface>> ClassList = new ArrayList<Class<? extends MyInterface>>();
there is no implements keyword in the world of generics. if you want a type parameter that implements an interface , use the extends keyword to represent it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With