I am trying to create a new LinkedListNode object as I parse through a char[] in reverse. Then I want to link these
char[] totalnum = (total + "").toCharArray();
for (int i = totalnum.length; i > 0; i--) {
LinkedListNode sum = new LinkedListNode(totalnum[i]);
sum.next = null;
}
Here is my LinkedListNode class:
public class LinkedListNode {
int data;
public LinkedListNode next;
// constructor
public LinkedListNode(int newData) {
this.next = null;
this.data = newData;
}
}
I was wondering how can I go about doing this. I am new to Java so this has gotten me stumped! I know I should create a new LinkedListNode object in each iteration but that is as far as I have gotten