
1006 CHAPTER 14 An Introduction to Data Structures
50 }
51
52 /** mutator for next
53 * @param nd the new value for next
54 */
55 public void setNext( IntegerNode nd )
56 {
57 next = nd;
58 }
59 }
EXAMPLE 14.1 The IntegerNode Class
The code for this class is straightforward. We code two constructors at lines
10 to 26. Both of these constructors set the value of next to null. This will be
the desired action when a node is created. However, to allow a client (which
will be the linked-list class) to reset the value of next as the list expands and
shrinks, we provide the setNext method.
14.1.3 Methods of a Linked List
For our class encapsulating a linked list, ...