ListNode head = new ListNode(list.get(0)); ListNode temp = head; for(int i=1;i<list.size();i++){ temp.next = new ListNode(list.get(i)); temp = temp.next; }