Suppose I have something like this
Class klazz = Integer.class;
And I'm interested in doing something like this
List<(klazz Class)> something = new ArrayList<>();
something.add(new Integer(..))
something.add(new Integer(..))
.. etc
I probably need to use reflection, yet however, I'm unsure about how to apply it.
Is it possible to do without reflection? If it's not, how would you find it suitable to implement?
Thanks in advance
klazzdoesn't really fit how generics work. I'd suggest just using aList<Object>and having some logic to ensure that only objects of typeklazzgo into it.klazzisString.class?List<Class>supposed to add onlyClasselements,new Integer(..)will not fit into this.