// Textbook fragment 03.24 /** Returns whether a given node has a previous node */ public boolean hasPrev(DNode v) { return v != header; } /** Returns whether a given node has a next node */ public boolean hasNext(DNode v) { return v != trailer; } /** Returns a string representation of the list */ public String toString() { String s = "["; DNode v = header.getNext(); while (v != trailer) { s += v.getElement(); v = v.getNext(); if (v != trailer) s += ","; } s += "]"; return s; } }