Foundation·Concept·2 min read

Java DSA basics

Practice this question

Common data structures in Java

  • ArrayList<T> for dynamic arrays
  • LinkedList<T> for list and queue operations
  • HashMap<K,V> for lookup by key
  • HashSet<T> for unique data
  • Queue<T> and Deque<T> for FIFO and stack-like behavior
  • PriorityQueue<T> for heap-based ordering
  • TreeSet<T> and TreeMap<K,V> for ordering
  • Arrays.sort() for sorting arrays
  • Collections.sort() for lists

Java interview rule

Use the correct collection for the problem. For example:

  • fast lookup → HashMap
  • sorted order → TreeMap or TreeSet
  • queue behavior → Queue / Deque
  • top-K → PriorityQueue

Adapted from 15_DSA_JAVA.md · “1. Java DSA basics”. Code examples are study fragments. Difficulty and core labels are editorial estimates; version-specific behavior should be checked against your project.