Variance
← Back to Generics - Parametric Polymorphism
Rules governing subtyping relationships between parameterized types. Covariance (List<Dog> is a subtype of List<Animal>) preserves the subtype relationship, contravariance reverses it, and invariance allows neither. Variance annotations ensure type safety when using generics with inheritance.