# Invariance

Published articles for Invariance.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Invariance

DevFeed: [Invariance](<https://devfeed.tech/articles/invariance-25018.md>)

Original publisher: [Read original article](<https://typealias.com/concepts/invariance/>)

Author: author@typealias.com (Dave Leeds)

Published: 2017-11-28T03:03:36Z

Content type: tutorial

Language: en

Sources: [Dave Leeds on Kotlin - typealias.com](<https://devfeed.tech/sources/dave-leeds-on-kotlin-typealias-com.md>)

Topics: [generics](<https://devfeed.tech/topics/generics.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Java](<https://devfeed.tech/topics/java.md>), [Polymorphism](<https://devfeed.tech/topics/polymorphism.md>)

Tags: [classes](<https://devfeed.tech/tags/classes.md>), [function](<https://devfeed.tech/tags/function.md>), [generic](<https://devfeed.tech/tags/generic.md>), [generics](<https://devfeed.tech/tags/generics.md>), [inheritance](<https://devfeed.tech/tags/inheritance.md>), [invariance](<https://devfeed.tech/tags/invariance.md>), [java](<https://devfeed.tech/tags/java.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [programming](<https://devfeed.tech/tags/programming.md>), [properties](<https://devfeed.tech/tags/properties.md>), [subtype](<https://devfeed.tech/tags/subtype.md>), [type-parameter](<https://devfeed.tech/tags/type-parameter.md>), [variance](<https://devfeed.tech/tags/variance.md>)

### AI overview

This tutorial explains invariance in generic subtyping. It shows that generic types can remain unrelated even when their component types have a subtype relationship, and discusses default invariance in Kotlin and Java, multiple type parameters, and variance in inherited properties and function types.

### Source excerpt

When dealing with simple classes, subtyping is straightforward. But once we start talking about generics, subtyping rules become more complicated, and we describe the subtyping rules in terms of variance. What is Invariance? Invariance describes a relationship between two sets of types where the complex types do not subtype at all, despite any subtyping that might exist for the component types. Does that sound confusing?1 Thankfully, it's way more easily demonstrated than defined, so let's look at an example.