Java adding to a unknown type generic list
问题 I've come into something I haven't come across before in Java and that is, I need to create a new instance of say the ArrayList class at runtime without assigning a known type then add data to the list. It sounds a bit vague so here is an example: Class<?> c = i.getClass(); Constructor<?> con = ArrayList.class.getConstructor(); ArrayList<?> al = (ArrayList<?>)con.newInstance(); al.add("something"); Now the reason I'm doing this versus just using generics is because generics are already being