In this chapter we’ll look at generics or type parameterization or generic programming in Scala. We’ll look at the following:
Syntax for generics: defining types and methods.
Bounded types, extends and super.
Wildcards in both Java and Scala.
Covariance and contravariance.
We talked briefly about subtype or inclusion polymorphism ; the idea that subtypes can be substituted to stand in for their super-types. These stand-ins can provide different behavior without changing the structure of your code. The types of polymorphism are:
Inclusion polymorphism (see Chapter 11, Inheritance).