Programming Tips - Java: What collections do you prefer?

Date: 2013aug30 Updated: 2020aug4 Language: Java Q. Java: What collections do you prefer? A. There are many collections classes but it pays to use a limited number. One good reason: so you can pass results from one function to another. Single-threaded:
java.util.ArrayList - growable array java.util.HashMap - hash (associative array) java.util.Stack - stack java.util.HashSet - set (check if something is a member) java.util.TreeSet - case insensitive set java.util.TreeMap - case insensitive hash
java.util.concurrent.LinkedBlockingQueue - queue for communication between threads java.util.concurrent.ConcurrentHashMap - better than Hashtable
In general, use java.util.concurrent over the older synchronized collections. Immutable: