Before Java 7, LinkedLists were created manually by the programmer, but starting with Java 7, the Java API now includes a LinkedList class. The LinkedList class operates very similar to an ArrayList.
- [Instructor] Another data structure in Java…is called a LinkedList.…Before Java 7, linked lists were created manually…by the programmer.…Starting with Java 7, the Java API now includes…a LinkedList class.…The LinkedList class operates very similar…to an ArrayList.…The biggest difference is the access to the elements…and a LinkedList is always linear…although it is bi-directional.…The LinkedList class uses a doubly linked list…to manage the collection of objects.…
This means that each node of the list contains a pointer…to the node that proceeds it and one to the node…that follows it which in turn means the list…can be traversed in either direction.…A node contains the element and the pointers required…for the next and previous node.…Here's an example.…If we have this LinkedList of some grocery items,…we have a pointer to the top of our list.…The first item is eggs.…The eggs item, or the eggs element, contains a pointer…to the next element in this case milk.…
Milk points to bread, and bread points to null.…Null indicates the end of the list.…
In this course, explore data structures in the Java language. Follow Peggy Fisher as she introduces you to several types of commonly-used data structures in Java. Peggy explores ArrayLists and LinkedLists, both of which implement the List interface, which extends the Collection interface and allows you to access list elements in a specific order. She also goes into the Vector, Stack, and Queue collection classes. To help you better understand these new concepts, Peggy wraps up the course with a challenge—creating a grocery list—and provides a solution for that challenge.
- Reviewing the types of data structures
- Working with the Collection interface and Iterable interface
- Working with ArrayLists and LinkedLists
- Using the Vector, Stack, and Queue collection classes