public static Node create() { final Node a = new Node(); a.setItem("A"); final Node b = new Node(); b.setItem("B"); a.setNext(b); final Node c = new Node(); c.setItem("C"); b.setNext(c); return a; }
public static void main(final String[] args) { Executor.execute(Ex19.class, args); Node first = create(); if (first.next == null) { first = null; } else { Node temp = first; while (temp.next.next != null) { temp = temp.next; } temp.next = null; } while (first != null) { StdOut.println(first.getItem()); first = first.next; } }