Java Collections Cheatsheet

Quick reference for Java collections: List, Set, Map, Queue, Deque, and utility methods.

ItemDescriptionExampleCategory
ArrayListResizable array implementationList<String> list = new ArrayList<>();List
LinkedListDoubly linked listList<Integer> ll = new LinkedList<>();List
VectorThread-safe dynamic arrayVector<String> v = new Vector<>();List
HashSetUnordered, unique elementsSet<String> hs = new HashSet<>();Set
LinkedHashSetInsertion-ordered setSet<Integer> lhs = new LinkedHashSet<>();Set
TreeSetSorted setSet<String> ts = new TreeSet<>();Set
HashMapKey-value hash mapMap<Integer,String> map = new HashMap<>();Map
LinkedHashMapInsertion-ordered mapMap<String,Integer> lhm = new LinkedHashMap<>();Map
TreeMapSorted map by keysMap<Integer,String> tm = new TreeMap<>();Map
PriorityQueueMin-heap or custom comparatorQueue<Integer> pq = new PriorityQueue<>();Queue
ArrayDequeResizable deque (stack/queue)Deque<String> dq = new ArrayDeque<>();Deque
CollectionsUtility class for sorting/shufflingCollections.sort(list); Collections.shuffle(list);Utility
ArraysUtility class for array operationsArrays.asList(1,2,3); Arrays.sort(arr);Utility