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. But how? How one can write a method similar to copyOf()?
How to create array of generic type? How does generic Arrays.copyOf() method work? It
Share
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:
where
Tis the generic type,cis the class ofTandsis the initial size.Documentation here