Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

YouTube

Choosing Between ArrayList and LinkedList in Java - Performance and Memory Considerations

Java via YouTube

Overview

Save Big on Coursera Plus. 7,000+ courses at $160 off. Limited Time Only!
Dive into a comprehensive 31-minute tutorial exploring the differences between ArrayList and LinkedList in Java's Collections Framework. Learn how to choose the optimal implementation for your application by benchmarking performance and analyzing memory consumption. Discover the impact of common operations, understand O(n) complexity, and utilize JMH for accurate benchmarking. Explore reading elements from different list positions, investigate pointer chasing, and compare iteration methods. Examine ArrayList's caveats, including insertion, deletion, and resizing. Compare insertion and addition operations between ArrayList and LinkedList, and analyze their memory footprints. Gain insights on optimizing memory usage with trimToSize() and wrap up with a thorough understanding of performance considerations for these essential Java data structures.

Syllabus

Intro
Choosing the best implementation for your use case
Choosing the most common operations for benchmark
Can you apply the On complexity to your use case?
Using JMH to run your benchmarks
Reading elements from the beginning and the end of a list
Reading elements from the middle of a list
Introducing pointer chasing
Benching the impact of pointer chasing on LinkedList
Iterating over a list with an index or an Iterator
Creating an array-based list to speed up your iterations
Wrapping up pointer chasing
ArrayList caveats: insertion, deletion, and resizing
Benching insertion and resizing for ArrayList
Comparing inserting and adding for ArrayList and LinkedList
Comparing the memory consumption of ArrayList and LinkedList
Reducing your memory footprint by using trimToSize
Wrapping up performances and memory consumption
Outro

Taught by

Java

Reviews

Start your review of Choosing Between ArrayList and LinkedList in Java - Performance and Memory Considerations

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.