Hi I'm working on this new linked list program. Basically what I wanted to do was move all of the data from the linked list into an array, then have the array print out backwards. I was wondering how I would do that. Some one suggested using a loop to me to do that, but I find that method confusing still
This part below that creates the ListNode elements.
To be honest, this seems to be less of a linked list, and more like, some code that manipulate a bunch of nodes that happen to be linked together.
Maybe it would be a good idea to implement the linked list first. Have instances of your linked list class maintain the head, tail, and other needed data. Have methods that can be called to add, insert, and remove elements -- these methods should not expose the node class. Or maybe implement an iterator.
Once you have a fully functioning linked list class, creating a "to array" method should be straightforward.