Non-Variance
Non-Variance is the most basic and easiest variance on parameterized types. According to non-variance or we can say in-variance there is no relationship between any of two parameterize type (as shown in diagram 10.1), even their type constructor accepts those parameters which have some inheritance hierarchy like our previous example Garage[Lamborghini]
is completely different type from Garage[Car]
even Car
is a supertype of Lamborghini
. By default when we creating our parameterized types they are non-variant.
We are creating three new parameterize type objects which are completely different from each other even Fruit
have an inheritance hierarchy.
Last updated