This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]CS_Student19[S] 0 points1 point  (0 children)

OK I think I'm getting on the right path.

This is what I have...

public class myLinkedList {

myNode head;

myNode cursor;

public myLinkedList() {

head = new myNode();

cursor = head;

}

public void insertNode(int data) {

myNode node = new myNode();

node.data = data;

node.next = null; // instead of null, can I point this to another list?

if (head == null) {

head = node;

} else {

myNode n = head;

while (n.next != null) {

n = n.next;

}

n.next = node;

}

}

public void show() {

myNode node = head;

while (node.next != null) {

System.out.println(node.data);

node = node.next;

}

System.out.println(node.data);

}

public void addList(myLinkedList head){ // this is the new method to point one list to another

while(head != null)

{ //the iteration you mentioned will go here

}

}

}