How can I instantiate an array
of object of a Generic Class?
I was implementing a Hash Table in Java
.
The Generic Class to be instantiated:
class GenericLinkedList<T> {
// Generic Class Codes Here
}
Hash Table Class:
public class HashTable {
private GenericLinkedList[] table; // Generic Class Instantiation
private static final int SIZE = 50;
public HashTable() {
this.table = new GenericLinkedList[SIZE];
for(int i = 0; i < SIZE; i++)
this.table[i] = new GenericLinkedList();
}
}