Improving performance with lists
A list is a fundamental data structure in the Java programming language. They give us the ability to easily create, store, and manipulate an ordered collection of elements. This data structure uses the java.util.list
interface and extends the java.util.Collection
interface.
In this section, we will take a close look at lists, why and when to use them, and techniques for getting the highest performance out of them.
Why use lists?
Perhaps the most common way of explaining what the list data structure can be used for is as a check-off/to-do list or a grocery shopping list. We create lists in our programs because we want to leverage one or more of its advantages:
- Ordered elements: Lists are used to maintain the order of our elements, even as we add new elements. This allows us to manipulate our data in a specific sequence. Consider a system log that has new entries added with date and time stamps. We would want those entries to be maintained...