This is the correct way to create an array:
@SuppressWarnings("unchecked") LinkedList<Long> [] hashtable = new LinkedList[10];
Cannot create arrays of parameterized types
You cannot create arrays of parameterized types. For example, the following code does not compile:
List<Integer>[] arrayOfLists = new List<Integer>[2];
The following code illustrates what happens when various types are inserted into an array:
Object[] strings = new String[2];
strings[0] = "hi";
strings[1] = 100;
, :
Object[] stringLists = new List<String>[];
stringLists[0] = new ArrayList<String>();
stringLists[1] = new ArrayList<Integer>();
, ArrayStoreException.
docs.oracle.com
, hashtable []?
, hashtable [0] Long in hashtable 1, LinkedList [] hashtable = new LinkedList [10]?
, LinkedList -. :
hashtable[0] = new LinkedList<String>();
LinkedList LinkedList:
@SuppressWarnings("unchecked") LinkedList<Long>[] hashtable = new LinkedList[10];
hashtable[0] = new LinkedList<Long>();
hashtable[1] = new MyLinkedList<Long>();
hashtable[2] = new LinkedList();
hashtable[3] = new MyLinkedList();
LinkedList, LinkedList []. , LinkedList:
LinkedList[] rawHashTable = hashtable;
rawHashTable[4] = new LinkedList<String>();
Object[] objectHashTable = rawHashTable;
objectHashTable[5] = "This line will throw an ArrayStoreException ";