How to create array of generic type? How does generic Arrays.copyOf() method work? It returns a copy of generic array. So it is possible to create generic arrays. B
Arrays.copyOf()
If you need to create it at runtime you need at least know the type at that very moment, so you could use the following approach:
a = (T[]) Array.newInstance(c,s);
where T is the generic type, c is the class of T and s is the initial size.
T
c
s
Documentation here