I am trying to add an array of integers to a Linked List. I understand that primitive types need a wrapper which is why I am trying to add my int elements as Integers. Thanks in advance.
int [] nums = {3, 6, 8, 1, 5};
LinkedList<Integer>list = new LinkedList<Integer>();
for (int i = 0; i < nums.length; i++){
list.add(i, new Integer(nums(i)));
Sorry - my question is, how can I add these array elements to my LinkedList?
LinkedList<Integer> list = new LinkedList<Integer>(Arrays.asList(nums));list.add(i, new Integer(nums(i))(accessing by index) inLinkedList. Just uselist.add(new Integer(nums(i)).