Using sequential implementations and interfaces
Let’s begin with the implementation. These are classes that manage the data in many ways. They are ArrayList
, LinkedList
, and ArrayDeque
.
ArrayList
This is a dynamic array-like structure. As a class, you must use methods rather than subscripts to access specific elements. You add elements at the end of the list. Once you add an element, you can read from it, write to it, search for a specific value, and remove elements from a specific position or that match a specific value.
You can instantiate an ArrayList
class with or without an initial capacity. If you do not specify a capacity, then it will default to a capacity of 10. If you know in advance how many elements you will need, then include that value when you instantiate the ArrayList
class. The auto-resizing of an ArrayList
class entails overhead that you can avoid if you know the precise size. In either case, you cannot access elements until you first add an element...