If you are a Java developer, you probably have already used ArrayList, or maybe HashSet, but do you know the difference between them? And the other collections?
Let’s see some implementations and the key features.
If you are using Java 21 or above, you also have the Sequence Collections, which brings more methods for sorted collections. These are some methods:
void addFirst(E)
void addLast(E)
E getFirst()
E getLast()
E removeFirst()
E removeLast()
As you can see, HashSet is not in this diagram, this happens because HashSet is not an ordered collection.
Conclusion
Each collection implementation has a specific purpose. Understanding each one better can help you choose the best approach for your problem.