Skip to main content

Section 04 · Stage 1: Learn Java

Java Collections

Generics and the Collections Framework: lists, sets, maps, queues and sorting, how they work inside, and how to choose the right one, with GitHub-ready projects.

What you will learn

  1. 4.1Generics7 lessons

    Write type-safe, reusable Java code with generic classes and methods, bounded types and wildcards, and understand the limits that type erasure brings.

    1. Why generics?35 min
    2. Write a generic class40 min
    3. Generic methods40 min
    4. Bounded types: <T extends …>40 min
    5. Wildcards: ?, ? extends, ? super45 min
    6. Type erasure and generic limits40 min
    7. Common mistakes and practice45 min
  2. 4.2The Collections Framework4 lessons

    Why collections replace arrays for changing data, how the Collection and Map family tree fits together, and how to pick the right collection for a job.

    1. Why collections, not arrays?25 min
    2. The collection family tree30 min
    3. Choosing the right collection30 min
    4. Common mistakes and practice40 min
  3. 4.3Lists10 lessons
  4. 4.4Sorting & Comparing4 lessons

    Give your own classes a natural order with Comparable, sort any data in any order with Comparator, and avoid the bugs that make sorts silently wrong.

    1. Natural order with Comparable35 min
    2. Custom order with Comparator35 min
    3. Sorting real data40 min
    4. Common mistakes and practice40 min
  5. 4.5Sets6 lessons

    Store unique values with HashSet, LinkedHashSet and TreeSet, make your own classes work in sets, and combine sets with union, intersection and difference.

    1. HashSet: no duplicates30 min
    2. Sets of your own objects35 min
    3. LinkedHashSet and TreeSet40 min
    4. Union, intersection and difference35 min
    5. Common mistakes and practice40 min
    6. Must-do problems: Sets150 min
  6. 4.6Maps11 lessons
  7. 4.7Queues, Stacks & Priority Queues6 lessons

    Handle waiting work in the right order with queues (first in, first out), stacks (last in, first out), deques (both ends) and priority queues (most important first).

    1. Queues: first in, first out35 min
    2. Stacks with ArrayDeque40 min
    3. Deque: both ends40 min
    4. PriorityQueue: always the smallest first40 min
    5. Common mistakes and practice45 min
    6. Must-do problems: Queues and Stacks150 min
  8. 4.8Utilities & Best Practices6 lessons

    Brings the section together: the Collections and Arrays helpers, the equals/hashCode rules every collection depends on, choosing by performance, and interview-level review.

    1. The Collections utility class35 min
    2. Immutable collections: List.of, Set.of, Map.of35 min
    3. Moving between arrays and collections35 min
    4. equals and hashCode in collections40 min
    5. Performance and choosing well40 min
    6. Collections interview questions and practice40 min
  9. 4.9Collections Mini Projects5 lessons

    Five console projects that put lists, sets, maps, queues and sorting to work, ending with a library system built entirely on collections.

    1. Student Gradebook60 min
    2. Word Frequency Analyzer60 min
    3. Contact Book60 min
    4. Task Scheduler70 min
    5. Library System with Collections90 min