![](https://cdn-media-1.freecodecamp.org/images/0*h03xxe8xFKcFv262.jpg)
An introduction to generic types in Java: covariance and contravariance
by Fabian Terh An introduction to generic types in Java: covariance and contravariance
Types
Java is a statically typed language, which means you must first declare a
variable and its type before using it. For example: int myInteger = 42; Enter generic types. Generic types
Definition [https://docs.oracle.com/javase/tutorial/java/generics/types.html…
Types
Java is a statically typed language, which means you must first declare a
variable and its type before using it. For example: int myInteger = 42; Enter generic types. Generic types
Definition [https://docs.oracle.com/javase/tutorial/java/generics/types.html…
![](https://upload.wikimedia.org/wikipedia/en/thumb/9/99/Question_book-new.svg/50px-Question_book-new.svg.png)
Noosphere – Wikipedia
The noosphere is a philosophical concept developed and popularized by the French philosopher and Jesuit priest Pierre Teilhard de Chardin and the biogeochemist Vladimir Vernadsky. Vernadsky defined the noosphere as the new state of the biosphere[1] and described as the planetary “sphere of reason”.[…
![](https://upload.wikimedia.org/wikipedia/en/thumb/b/b4/Ambox_important.svg/40px-Ambox_important.svg.png)
Strong and weak typing – Wikipedia
In computer programming, programming languages are often colloquially classified as to whether the language’s type system makes it strongly typed or weakly typed (loosely typed).
![](https://upload.wikimedia.org/wikipedia/en/thumb/b/b4/Ambox_important.svg/40px-Ambox_important.svg.png)
Type system – Wikipedia
This article is about type systems from the point-of-view of computer programming. For a theoretical formulation, see type theory.
![](https://upload.wikimedia.org/wikipedia/en/thumb/9/99/Question_book-new.svg/50px-Question_book-new.svg.png)
Programming paradigm – Wikipedia
This article is about classification of programming languages. For definition of the term “programming model”, see Programming model.
![](https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/Sound-icon.svg/20px-Sound-icon.svg.png)
Functional programming – Wikipedia
In computer science, functional programming is a programming paradigm—a style of building the structure and elements of computer programs—that treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data. It is a declarative programming paradigm in that p…
![](https://upload.wikimedia.org/wikipedia/en/thumb/b/b4/Ambox_important.svg/40px-Ambox_important.svg.png)
Type conversion – Wikipedia
In computer science, type conversion,[1][2] type casting,[1][3] type coercion,[3][3] and type juggling[4][5] are different ways of changing an expression from one data type to another. An example would be the conversion of an integer value into a floating point value or its textual representation as…
Polymorphism
Ad hoc polymorphism: defines a common interface for an arbitrary set of individually specified types.
Parametric polymorphism: when one or more types are not specified by name but by abstract symbols that can represent any type.
Subtyping (also called subtype polymorphism or inclusion polymorphism): when a name denotes instances of many different classes related by some common superclass.[3]
Parametric polymorphism: when one or more types are not specified by name but by abstract symbols that can represent any type.
Subtyping (also called subtype polymorphism or inclusion polymorphism): when a name denotes instances of many different classes related by some common superclass.[3]
![](https://upload.wikimedia.org/wikipedia/en/thumb/9/99/Question_book-new.svg/50px-Question_book-new.svg.png)
Parametric polymorphism – Wikipedia
Parametric polymorphism is a way to make a language more expressive, while still maintaining full static type-safety. Using parametric polymorphism, a function or a data type can be written generically so that it can handle values identically without dependi…
![](https://upload.wikimedia.org/wikipedia/en/thumb/d/d1/Inheritance.svg/350px-Inheritance.svg.png)
Subtyping – Wikipedia
(also subtype polymorphism or inclusion polymorphism) is a form of type polymorphism in which a subtype is a datatype that is related to another datatype (the supertype) by some notion of substitutability, meaning that program elements, typically subroutines…
Covariance and contravariance
Many programming language type systems support subtyping. Variance refers to how subtyping between more complex types relates to subtyping between their components. Depending on the variance of the type constructor, the subtyping relation of the simple types may be either preserved, reversed, or ignored for the respective complex types.