Interactive tutorial

Collections, Generics, and Streams in Java

Learn to choose Java collections, build type-safe generic APIs, and process data with readable Stream pipelines. Using a small book catalog, you will handle mutability, equality, wildcard bounds, transformations, optional results, and collectors, then combine these skills in a complete program you can run locally.

  • Level: Intermediate
  • Duration: approx. 1 h 21 min
  • 12 steps
Collections, Generics, and Streams in Java

What you will go through

  1. Step 1 of 12 5 min Choose the Right Collection Contract Choose List, Set, and Map contracts, then select implementations based on ordering, uniqueness, and lookup requirements in a book catalog.
  2. Step 2 of 12 6 min Control Mutation, Copies, and Views Choose a mutable working list when a catalog must change, and distinguish an unmodifiable snapshot from an unmodifiable view of a backing list.
  3. Step 3 of 12 7 min Make Equality and Ordering Explicit Use record equality, hashing rules, and comparator tie-breakers to predict collection membership and deterministic ordering.
  4. Step 4 of 12 7 min Build Type-Safe Generic Classes and Methods Create small generic classes and methods that keep stored, input, and returned values connected by a shared type.
  5. Step 5 of 12 7 min Design Flexible APIs with Wildcards Use PECS to design a flexible, type-safe method that copies values between compatible lists.
  6. Step 6 of 12 5 min Understand How a Stream Pipeline Executes Build and trace a safe sequential Stream pipeline that filters the book catalog and counts matching books.
  7. Step 7 of 12 6 min Transform and Flatten Typed Data Transform catalog books into titles and flatten nested reading lists while tracking the stream element type at every stage.
  8. Step 8 of 12 5 min Deduplicate and Rank Stream Results Rank complete stream results deterministically and understand how the current element type controls deduplication.
  9. Step 9 of 12 8 min Handle Optional Results and Numeric Reductions Choose safe terminal operations for boolean checks, optional first matches, and page-count reductions.
  10. Step 10 of 12 6 min Collect Results into Lists, Sets, and Maps Choose stream collectors based on explicit requirements for mutable results, encounter order, uniqueness, ID lookup, and duplicate-key handling.
  11. Step 11 of 12 7 min Build Grouped and Partitioned Summaries Create typed reports with grouping collectors, ordered genre totals, and boolean partitions.
  12. Step 12 of 12 12 min Apply the Full Workflow to a Catalog Report Complete and run a self-contained Java 17 catalog report that integrates safe copying, generic helpers, deterministic streams, unmodifiable results, and grouped totals.

Video Courses

Courses related to this topic

See all video courses

Download the App now to have access to + 5000 free courses, exercises, certificates and lots of content without paying anything!

  • 100% free online courses from start to finish

    Thousands of online courses in video, ebooks and audiobooks.

  • More than 60 thousand free exercises

    To test your knowledge during online courses

  • Valid free Digital Certificate with QR Code

    Generated directly from your cell phone's photo gallery and sent to your email

Cursa app on the ebook screen, the video course screen and the course exercises screen, plus the course completion certificate