class GaoJi class ZhongJi extends GaoJi //协变=========================== class Card[+T] val cgaoji = new Card[GaoJi] val czhongji = new Card[ZhongJi] //协变之后Card[ZhongJi]犹如继承了Card[GaoJi] def test(card: Card[GaoJi]): Unit = { println(123) } test(cgaoji) test(czhongji) //逆变=========================== class Card1[-T] val cgaoji1 = new Card1[GaoJi] val czhongji1 = new Card1[ZhongJi] //逆变之后Card[GaoJi]犹如Card[ZhongJi]的父类也可被接收 def test1(card: Card1[ZhongJi]): Unit = { println(678) } test1(cgaoji1) test1(czhongji1)