English
Topic 9. Generic programming (generics)
Goal: learn to create type-safe containers and algorithms, choose sufficient parameter bounds, and test their contracts.
Lecture contents
- Type parameters, classes, and methods — From Object to a type parameter · Generic classes, records, and diamond · Generic methods and type argument inference
- Bounds and invariance — Bounded type parameters · Invariance and the difference from arrays
- Wildcards and the PECS principle — Wildcards and the PECS principle · Wildcard capture and helper methods
- Type erasure and its consequences — Type erasure and generated bridges · Generics restrictions · Example 4. An array-based stack
- Raw types and standard contracts — Raw types and heap pollution · Generic results and standard contracts