Skip to Main Content
Java 6 Illuminated: An Active Learning Approach, 2nd Edition
book

Java 6 Illuminated: An Active Learning Approach, 2nd Edition

by Julie Anderson, Herve J. Franceschi
February 2008
Intermediate to advanced content levelIntermediate to advanced
1288 pages
39h 39m
English
Jones & Bartlett Learning
Content preview from Java 6 Illuminated: An Active Learning Approach, 2nd Edition
Before inserting or deleting
an item in a linked list rep-
resenting a queue,always
check if the linked list is
empty.Not doing so results
in a NullPointerException at
run time.
COMMON ERROR
TRAP
14.5 Array Representation of Stacks 1043
If the list is not empty, control skips to line 30, where we attach pn at the end
of the list by setting the next instance variable of tail to pn. We then assign pn
to tail in order to reflect that pn is now the last node of the list. Finally, and in
all cases (empty list or not), we increment numberOfItems by 1 at line 33.
Figures 14.10a to 14.10d show the impact on the list of executing lines 22,
30, and 31 step by step ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

JFC Swing Tutorial, The: A Guide to Constructing GUIs, Second Edition

JFC Swing Tutorial, The: A Guide to Constructing GUIs, Second Edition

Kathy Walrath, Mary Campione, Alison Huml, Sharon Zakhour
Java Illuminated, 4th Edition

Java Illuminated, 4th Edition

Julie Anderson, Hervé J. Franceschi

Publisher Resources

ISBN: 9780763749637