
Include an instance vari-
able in the linked-list class
to store the number of
items in the list for quick
and direct access to that
information as needed.
SOFTWARE
ENGINEERING TIP
1004 CHAPTER 14 An Introduction to Data Structures
Thus, the IntegerNode class is defined using an object reference of its own
type. Indeed, one of its instance variables is an IntegerNode object refer-
ence.
We define our two instance variables using the following statements:
private int data;
private IntegerNode next;
Based on this definition of the IntegerNode class, we need only one instance
variable in the linked-list class, a reference to the first node, which we call
the ...