create generic array java code example
Example 1: java generic array
public <T> T[] getArray(int size) {
T[] genericArray = (T[]) new Object[size];
return genericArray;
}
Example 2: initialize generic array java
//It is recommended to use collections of generics because arrays of generics are a bit problematic in some cases
List<String>[] arrayOfList=(List<String>[])new List[100]();