Java course

Java Level 4: Collections & Generics

Collections & Generics is level 4 of 16 of the LoWisa Java course. It has 3 lessons and 9 ideas. Below is every lesson and what it teaches, in one line each.

Updated 2026-11-16

Lists, Sets and Maps

  • List. A List is an ordered collection: ArrayList backs it with a growable array, the everyday default.
  • Set. A Set holds each element once: HashSet answers contains in constant time via hashing.
  • Map. A Map pairs keys with values: HashMap is the lookup table most Java programs are built around.

Generic Types

  • Generics. Generics parameterise types: List<Order> can only hold orders, checked at compile time, no casts.
  • Type erasure. Generics are erased at runtime: the JVM sees plain List, which is why new T() cannot compile.
  • Bounded types. A bound like <T extends Comparable<T>> demands capability: sort only what can compare itself.

Choosing Appropriate Collections

  • Choosing by operation. Choose by the hot operation: random access wants ArrayList, membership wants HashSet, ordering wants TreeMap.
  • equals and hashCode. Hash collections trust equals and hashCode together: override one without the other and elements vanish.
  • Immutable collections. List.of and Map.of build immutable collections: safe to share, impossible to corrupt.

Before and after this level

In the app each of these ideas is taught and then asked back, and the level ends with a checkpoint and flashcards. See Checkpoints and flashcards.

Frequently asked questions

What does Java Level 4: Collections & Generics cover?

Lists, Sets and Maps, Generic Types, Choosing Appropriate Collections: 3 lessons and 9 ideas.

What should I know before this level?

The level before it, Level 3: Interfaces & Polymorphism, which covers Interfaces and Abstract Classes, Dynamic Dispatch, Designing Flexible Object Models.

Learn Java on your phone

The first level is free. LoWisa is on Google Play and the App Store.