Chapter 4

Using the LinkedList Class

In This Chapter

arrow Introducing linked lists

arrow Comparing linked lists with array lists

arrow Creating linked lists

arrow Adding items to a linked list

arrow Retrieving items from a linked list

arrow Updating and deleting items in a linked list

The ArrayList class, which I cover in the preceding chapter, is a collection class that's based on an array. Arrays have their strengths and their weaknesses. The strength of an array is that it's very efficient — at least until you fill it up or try to reorganize it by inserting or deleting elements. Then it suddenly becomes very inefficient.

Over the years, computer scientists have developed various alternatives to arrays that are more efficient for certain types of access. One of the oldest of these alternatives is the linked list. A linked list is less efficient than an array for tasks such as directly accessing an element based on ...

Get Java All-in-One For Dummies, 4th 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.