Arrays 在java中插入到链表数组中

Arrays 在java中插入到链表数组中,arrays,dynamic,insert,linked-list,hashtable,Arrays,Dynamic,Insert,Linked List,Hashtable,我有一个链表数组,我通过以下操作初始化该数组: hashTable = (T[]) new Object[tableSize]; for(int i = 0; i < tableSize; i++){ hashTable[i] = (T) new LinkedList<T>(); // I want to add something to a linked list at element i of the array hashTable[i].inse

我有一个链表数组,我通过以下操作初始化该数组:

hashTable = (T[]) new Object[tableSize];

for(int i = 0; i < tableSize; i++){
    hashTable[i] = (T) new LinkedList<T>();
    // I want to add something to a linked list at element i of the array
    hashTable[i].insert(item);
}
hashTable=(T[])新对象[tableSize];
for(int i=0;i
插入数组中的链表的正确方法是什么?

调用“插入”列表的方法。 如果你想访问这个方法,你需要给你的数组一个类型(列表)

List[] hashTable = new List[tableSize]; // terrible name for an array

for(int i = 0; i < tableSize; i++){
    hashTable[i] = new LinkedList<T>();
    // I want to add something to a linked list at element i of the array
    hashTable[i].add(item);
}
List[]hashTable=新列表[表大小];//数组的可怕名称
for(int i=0;i