Type Variance in Java and Kotlin
summary
Covers variance of generic types on the JVM, tracing its evolution from Java’s covariant arrays and Java wildcard types to Kotlin’s declaration-site and use-site variance. Explains when and how to design flexible, maintainable APIs using covariance and contravariance in classes and methods, with progressively complex examples.
AI-written summary · about
chapters (9)
- 0:00Introduction
- 2:10What is type variance
- 8:13Array covariance in Java
- 14:14Generic invariance in Java
- 23:32Variance in Kotlin
- 34:15Contravariance in Kotlin
- 39:33PEC S rule in Java
- 41:17Java problems and Kotlin solutions
- 46:55Summary








