Chapter 4

Using the LinkedList Class


check Introducing linked lists

check Comparing linked lists with array lists

check Creating linked lists

check Adding items to a linked list

check Retrieving items from a linked list

check 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, 5th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.