Why this is wrong:
Class extends Number> type = Integer.class;
ArrayList = new ArrayList<>();
?
I
Taken literally, the other answers' suggestions of how to implement createAList are ignoring something important: due to type erasure, such a method is pointless.
Given you want a List extends Number>, you can just write this:
List extends Number> lst = new ArrayList<>();
If you just wanted a List>, you could write:
List> lst = new ArrayList<>();
If you were in the scope of a type parameter T and wanted a List, you could write:
List lst = new ArrayList<>();
Notice that a Class object has nothing to do with these constructor calls, just like the methods in the other answers. That's because at runtime, the ArrayList instance doesn't know or care about whatever generic type its references had at runtime.