Covariance, Contra-variance implementation for Generic List in Java. Important programming concepts

preview_player
Показать описание
Covariance, Contravariance implementation for Generic List in Java, Generic List and Arrays comparison. Important Java programming concepts.
Рекомендации по теме
Комментарии
Автор

Great video!
In summary:
covariant: super accepts sub types, ie Number[] a = new Integer[] (number is super to Integer)
invariant: super does not accept sub types
covariant: sub-types accepts its super

BoonkiCoC
Автор

I understand the syntax, but I just cant understand the why. I understand covariant, but why do we have contravariance ? Whats the need for this ?

peshutanpavri
Автор

What is the purpose of such a list that you can't add any element? 5:10

Adriano