// Singly linked list // class MyList { private T value; private MyList next; public T setValue(T V) { value = V; return V; } public MyList setNext(MyList N) { next = N; return next; } public T getValue() { return value; } public MyList getNext() { return next; } public String toString() { MyList A = this; String S = "["; while (A != null) { S = S + A.value.toString() + " "; A = A.next; } return S+ "]"; } public String toString1() { if (next == null) return value.toString() + "]"; else return value.toString() + " " + next.toString1(); } } // end MyList