I created an arraylist of LinkedLists in the following manner:
ArrayList<LinkedList<Card>> list = new ArrayList<>(5);
I then needed to add the linkedlists to the arrayList so I did this, which did not seem to work as the ArrayList remained empty
for (position = 0; position < list.size(); position++) {
list.add(new LinkedList<Card>());
}
So then I manually added linkedLists to the arrayList by giving the LinkedLists references:
LinkedList<Card> temp_list0 = new LinkedList<Card>();
LinkedList<Card> temp_list1 = new LinkedList<Card>();
LinkedList<Card> temp_list2 = new LinkedList<Card>();
LinkedList<Card> temp_list3 = new LinkedList<Card>();
LinkedList<Card> temp_list4 = new LinkedList<Card>();
list.add(temp_list0);
list.add(temp_list1);
list.add(temp_list2);
list.add(temp_list3);
list.add(temp_list4);
Finally, though each iteration, i needed to pull out one of the LinkedLists to add something to it and then put it back where it was in the arraylist but by doing this I lose the reference to the LinkedList and thus the information is lost
for (position = 0; position < deck.length; position++) {
scan = (deck[position]).getValue();
temp_list = list.get(scan);
temp_list.offer(deck[position]);
list.add(scan, temp_list);
}
Is there a better way to access to the LinkedLists in the arraylist without losing information, because my way does not work.