February 2014
Beginner
1248 pages
62h 25m
English
Generic class ListNode (Fig. 21.3, lines 6–37) declares package-access fields data and nextNode. The data field is a reference of type T, so its type will be determined when the client code creates the corresponding List object. Variable nextNode stores a reference to the next ListNode object in the linked list (or null if the node is the last one in the list).
Lines 42–43 of class List (Fig. 21.3, lines 40–47) declare references to the first and last ListNodes in a List (firstNode and lastNode, respectively). The constructors (lines 47–50 and 53–57) initialize both references to null. The most important methods of class List are insertAtFront (lines 60–66), insertAtBack (lines 69–75), removeFromFront ...
Read now
Unlock full access