public class LLDemo { public static void main(String[] args) { IntNode head = null; head = new IntNode(15,head); head.addNodeAfter(23); head = new IntNode(42,head); head.addNodeAfter(19); printList1(head); System.out.println("-----------------------------"); IntNode x = IntNode.listPosition(head, 2); System.out.println("Position 2 = " + x.getData()); System.out.println("-----------------------------"); IntNode y = IntNode.listSearch(head, 15); y.removeNodeAfter(); printList2(head); } //--------------------------------------- public static void printList1(IntNode h) { int length = IntNode.listLength(h); System.out.println ("Length of list is " + length); for (int i = 1; i <= length; i++) { System.out.println(i + ": " + h.getData()); h = h.getLink(); } } //--------------------------------------- public static void printList2(IntNode h) { int count = 1; while (h != null) { System.out.println(count + ": " + h.getData()); h = h.getLink(); count++; } } }