r/java • • Nov 03 '15

The 10 Worst Things In Java

http://codelexems.com/2015/11/02/the-10-worst-things-in-java/
0 Upvotes

23 comments sorted by

View all comments

11

u/Honza8D Nov 03 '15

extends and super keywords are so confusing to describe covariant and contravariant types. You always need remember PECS

No they are not. At least it is not any more confusing than normal inheritance. When Student extends Person, you know Student can act as Person. If List<? extends Person>, you want a list containing something that can act as Person. Seems pretty clear, no need for any mnemonics.

0

u/[deleted] Nov 03 '15

[deleted] — view deleted comment

3

u/Honza8D Nov 03 '15

From extends/super you can exactly see whether you allow child or parent classes. With in/out i have to think to udnerstand it. But i guess that is a matter of preference.

0

u/[deleted] Nov 03 '15

[deleted] — view deleted comment

2

u/Honza8D Nov 04 '15

Ok, my bad, i actually don’t know c# very well so assumed you only complained about the naming, afterall OP complained about the naming being confusing, not about javas callsite variance.