12.3 Linked Data Structures

Do not mistake the pointing finger for the moon.

—ZEN SAYING

A linked data structure is a collection of objects, each of which contains data and a reference to another object in the collection. We will confine most of our discussion of linked data structures to a simple but widely used kind known as a linked list.

The Class LinkedList

Instead of using the class ArrayList and worrying about allocating too much memory, we can use an instance of the class LinkedList, which is also in the package java.util of the Java Class Library. Like ArrayList, LinkedList is another implementation of the ADT list. Although the two classes do not have the same methods, both have the same basic list operations ...

Get Java: An Introduction to Problem Solving and Programming, 8th 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.