
There are many ways to
code the deletion of a node
in the list.Try to write code
that is easy to read and
maintain.
SOFTWARE
ENGINEERING TIP
When traversing a list,
always test if a node refer-
ence is null before calling a
method using that refer-
ence.Failure to do so might
result in a NullPointerExcep-
tion at run time.More gen-
erally,when coding a
linked-list method,always
pay attention to the possi-
bility of an object reference
being null before using
that reference to call a
method.
COMMON ERROR
TRAP
Short-circuit evaluation of
logical expressions is dis-
cussed in Chapter 5.
REFERENCE POINT
1014 CHAPTER 14 An Introduction to Data Structures
If we reversed the ...