private class Node implements Cloneable
1: private class Node implements Cloneable
2: {
3: private T data;
4: private Node next;
5:
6: /* < Constructors >
7: . . .
8:
9: < Accessor and mutator methods getData, setData, getNextNode,
10: and setNextNode >
11: . . . */
12:
13: protected Object clone()
14: {
15: Node theCopy = null;
16: try
17: {
18: @SuppressWarnings("unchecked")
19: Node temp = (Node)super.clone();
20: theCopy = temp;
21: }
22: catch (CloneNotSupportedException e)
23: {
24: throw new Error(e.toString());
25: }
26:
27: @SuppressWarnings("unchecked")
28: T temp = (T)data.clone();
29: theCopy.data = temp;
30: theCopy.next = null; // Don't clone link; it's set later
31:
32: return theCopy;
33: } // end clone
34: } // end Node
35: // Version 4.0
36: