Generics

Java generics: type parameters, what the compiler checks, type erasure, wildcards, and what erasure forbids.

  • 9 cards
  • 5 questions
  • About 9 min
  • Intermediate to Advanced
Share

Generics: the type parameters in List<String> that let the compiler check what goes into a collection. Generics exist to move errors earlier, and their strange rules nearly all come from one fact: the type parameter is gone by the time the code runs. It covers what a type parameter buys, erasure, why a List<String> is not a List<Object>, extends and super wildcards, and what you cannot write with T. It leaves out writing generic methods with recursive bounds.

Contents

9 cardsnot started