Types of Collections
Types of Collections: Lists, Maps, Sets, Queues, Stacks.
Updated
- Lists (Apprentice): Lists keep items in order. An ArrayList is fast at reading by position, and a LinkedList is fast at adding and inserting.
- Maps (Apprentice): Maps store values under unique keys. HashMap is fastest, LinkedHashMap keeps the order you added entries, and TreeMap sorts by key.
- Sets (Journeyman): A set holds each value only once, and HashSet, LinkedHashSet and TreeSet differ in the order they give back the values.
- Queues (Journeyman): A queue is a collection that allows you to access the elements in the order in which they were added instead of by ordinal position.
- Stacks (Journeyman): A Stack is a collection that allows you to access the elements in the reverse order in which they were added to the collection.