This only prints out "0" and I want it to print out "01"
ListNode fakehead = new ListNode(0);
ListNode node = null;
fakehead.next = node;
node = new ListNode(1);
However this prints out "012"
ListNode fakehead = new ListNode(0);
ListNode node = new ListNode(1);
fakehead.next = node;
node.next = new ListNode(2);
Why can't I set node = null and then initialize it to print out "01"?
What is the correct convention/code to do this? I would like to create new nodes on fakehead.next?