// Textbook fragment 06.13 /** Returns a textual representation of a given node list */ public static String toString(PositionList l) { Iterator it = l.iterator(); String s = "["; while (it.hasNext()) { s += it.next(); // implicit cast of the next element to String if (it.hasNext()) s += ", "; } s += "]"; return s; }