21.4.1 Singly Linked Lists

Linked list nodes normally are not stored contiguously in memory. Rather, they’re logically contiguous. Figure 21.2 illustrates a linked list with several nodes. This diagram presents a singly linked list—each node contains one reference to the next node in the list. Often, linked lists are implemented as doubly linked lists—each node contains a reference to the next node in the list and a reference to the preceding one.

Image

Fig. 21.2 | Linked-list graphical representation.

Image Performance Tip 21.3

The elements of an array ...

Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.