Type dependency in Java, Part 1

See the original posting on JavaWorld

Understanding type compatibility is fundamental to writing good Java programs, but the interplay of variances between Java language elements can seem highly academic to the uninitiated. This article is for software developers ready to tackle the challenge! Part 1 reveals the covariant and contravariant relationships between simpler elements such as array types and generic types, as well as the special Java language element, the wildcard. Part 2 explores type dependency and variance in common API examples and in lambda expressions.


Get the source code for this article, “Type dependency in Java, Part 1.”
Created for JavaWorld by Dr. Andreas Solymosi.

Concepts and terminology

Before we get into the relationships of covariance and contravariance among various Java language elements, let’s be sure that we have a shared conceptual framework.

To read this article in full or to leave a comment, please click here