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: generic array creation java
Node<T>[] arr = new Node[0];
public <T> T[] getArray(int size) {
T[] genericArray = (T[]) new Object[size];
return genericArray;
}
Node<T>[] arr = new Node[0];