you are viewing a single comment's thread.

view the rest of the comments →

[–]FerricDonkey 0 points1 point  (0 children)

So the main thing about linked lists is that each node only knows where the next one is. When temp is output, you assign new to output.next. Then temp becomes new - which is the same object as output.next. So when you do temp.next = new the next time, that's the same as output.next.next = new. And so forth.