nodetest - n2.data = "T" n2.next...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
public class nodetest { public static void main(String[] args) { Node n1, n2, n3; n1 = new Node(); n2 = new Node(); n1.data = "X"; n2.data = "J"; n1.next = n2; n3 = new Node; n3.data = "G"; n2 = null; n1.next.next = n3; n3 = null; n1.next.next.next.next = new Node(); n1.next.next.next.next.data = "Z"; n n2 = new Node();
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: n2.data = "T" n2.next = n1; n1 = n2; n2 = null; n n2 = new Node(); n2.data = "W"; n2.next = n1.next.next.next.next; n2.next.next.next.next = n2; n // delete head n1 = n1.next; n // delete last n2.next = null; n // delete middle n1.next = n1.next.next } }...
View Full Document

Ask a homework question - tutors are online