Generics & Variance

KOTLIN › Types & Classes

Kotlin generic types, in/out variance, projections, erasure, and reified type parameters.

Variance and erasure are classic Kotlin interview filters: they reveal whether you understand subtyping rules versus just syntax. Expect to explain why a List<Dog> can stand in for a List<Animal>, when the compiler rejects a producer/consumer position, and why reified only exists inside inline functions. Interviewers probe declaration-site versus use-site variance, star projection meaning, and what survives type erasure at runtime.

What this covers

Study this topic

Further reading