Data Structures — Chapter 16
Sorting in Java can be easily done using tools for collecting and manipulating your data, without having to write your own sort algorithms. The Java Collections Framework’s data structure will help us achieve this.
Few important data structures from Java
- TreeSet — Keeps the elements sorted and prevents duplicates.
- HashMap — Let’s you store and access elements as name value pairs.
- LinkedLis — Designed to give better performance when you insert or delete elements from the middle of the collection. (In practice, an ArrayList is still usually what you want)
- HashSet — Prevents duplicates in the collection, and given an element, can find that element in the collection quickly.
- LinkedHashMap — Like a regular HashMap, except it can remember the order in which elements (name/value pairs) were inserted, or it can be configured to remember the order in which elements were last accessed.