Java for Humans {Data Structures: LinkedLists}

Lincoln W Daniel
ModernNerd Code
Published in
6 min readJan 18, 2016

--

View Table of Contents | Download Supporting Code | Subscribe to ModernNerd Youtube Channel for Coding Videos | By Lincoln W Daniel

Our phone book from the Arrays chapter could only hold a fixed number of our friends’ contact information because it was made with an array. We bounded our phone book by implementing it as an array because it makes sense: your phone only has a limited amount of storage space, so we can only store a limited amount of contacts. Arrays are best when you know how many elements you will be collecting, but there are other situations where it doesn’t make sense to bound the capacity of our collection. For those situations, dynamically expanding lists are best.

Why Lists are Important & Useful

Unlike arrays, lists in Java can expand without bounds. You may use a list to accumulate and collect things you don’t know the bounds of, such as the people you meet in your life time, the places you’ve been, the skills you learn, the movies you want to watch. If you’ve ever heard of a “Bucket List”, it is the best application of a list: toss everything you want to do into the bucket and mark them as done as you accomplish them.

The Java List class is an interface from which we can implement any kind of list subclass we’d like. Java provides us two popular implementations of the List interface — LinkedList and ArrayList — but we will focus on the LinkedList in this chapter because you already know much of how…

--

--

Lincoln W Daniel
ModernNerd Code

Chief Bull @ BullAcademy.org ® Elevating writers @ ManyStories.com. Author @JavaForHumans Ex: Editor in Chief MarkGrowth (acq.), Engineer @Medium @GoPuff