Practice Collections in Java

Work with Java Collections Framework including List, Set, Map, and Queue.

Work through 22 exercises with starter code, expected output, test cases, and hints.

Collections exercises

  1. ArrayList Basics Java exercise — Create and use ArrayList
  2. HashSet Basics Java exercise — Use HashSet for unique elements
  3. HashMap Basics Java exercise — Store key-value pairs
  4. List Iteration Methods Java exercise — Different ways to iterate a list
  5. Queue Operations Java exercise — Use Queue for FIFO operations
  6. Stack Operations Java exercise — Use Stack for LIFO operations
  7. Word Frequency Counter Java exercise — Count word frequencies in a sentence
  8. Remove Duplicates from List Java exercise — Remove duplicates while preserving order
  9. List Intersection Java exercise — Find common elements between two lists
  10. Sort Map by Value Java exercise — Sort a map by its values
  11. Group By Property Java exercise — Group elements by a property
  12. Simple LRU Cache Java exercise — Implement a simple LRU cache
  13. Priority Queue with Custom Order Java exercise — Use PriorityQueue with custom comparator
  14. Two Sum with HashMap Java exercise — Find pair with target sum using HashMap
  15. First Unique Element Java exercise — Find first element that appears once
  16. Merge K Sorted Lists Java exercise — Merge multiple sorted lists into one
  17. Stack Using Queues Java exercise — Implement a stack using only queues
  18. Group Anagrams Java exercise — Group words that are anagrams of each other
  19. Sliding Window Maximum Java exercise — Find maximum in each sliding window
  20. Top K Frequent Elements Java exercise — Find the k most frequent elements
  21. Merge Intervals Java exercise — Merge overlapping intervals
  22. Task Scheduler Java exercise — Find minimum time to complete all tasks with cooldown

Browse the complete Java practice path · Open the online Java compiler