A linked list is a collection in which every object in the list maintains with it a pointer to the following object in the list and to the preceding object in the list. No array is involved at all in a linked list. Instead, the list is managed entirely by these pointers.
LinkedList class has several compelling advantages over the
Size issues: Because the
ArrayList class uses an internal array to store list data, the
ArrayList class frequently has to reallocate its array when you add items to the list. Linked lists don’t have any size issues. You can keep adding items to a linked list until your computer runs out of memory.
Inserting items: With the
ArrayList class, inserting an item in the middle of the list is inefficient because all items after the insertion point must be copied. With a
LinkedList class, though, inserting items in the middle of the list is much more efficient.
Removing items: With an array list, ...