package Scaladay02kcomkawr
** // Covariance and /
**
is the generic definition *** java left and right sides of generics to be consistent
-
For example polymorphism in two ways to look at is not allowed
-
List list = new ArrayList();
-
List list2 = new ArrayList();
-
Under scala in default it is not allowed but is very flexible scala
-
Thus adding the definition of the generic symbol [+ T] covariant [-T] The inverter is the case of two or more can be achieved
-
Covariant superclass refers to the right-hand side when the left generic
-
Inverter means is a left side of the equal sign on the right side is a subclass of the generic generic
-
Multi set for operation to do **
/ *
Object CovarianceInversion {
DEF main (args: the Array [String]): Unit = {
Val List: the Test [Object] = new new the Test Personval list1:Test01[person]=new Test01Object
}
}
// define covariant
class Test [+ T] {
}
// define inverter
class Test01 [-T] {
}
class person {
“类”
}