Why do we need "? extends" in Java
stackoverflow.com
Why do we need "? extends" in Java
1–10 of 28 posts
Re: Why do we need "? extends" in Java
#2Re: Why do we need "? extends" in Java
#3Re: Why do we need "? extends" in Java
#4Re: Why do we need "? extends" in Java
#5Wow, I'm so glad that I don't need to worry about such a mess when using duck-typing in Python.
Re: Why do we need "? extends" in Java
#6Re: Why do we need "? extends" in Java
#7Wow, I'm so glad that I don't need to worry about such a mess when using duck-typing in Python.
In Python, the deploy/run unit tests/spot typo cycle greatly slows me down.
Re: Why do we need "? extends" in Java
#8I hope when writing Java code sometimes at a job, I can refer to this again.
This is all done in the name of type safe programming (I don't know the exact english terminology).
is called covariance. It helps to access attributes of B and derived classes with get() but prevents to use set().
ArrayList list;
list = new ArrayList();
list = new ArrayList();
list = new ArrayList();
list.set(index, myInteger); // throws error
Compiler has to know the exact type to set the value, but Long, Double and Integer are all from type Number, so you can read it into a Number variable.
Is that correct?
Re: Why do we need "? extends" in Java
#9Why do we need Java?
How about that?
Have you tried programming BEFORE Java, when the same kind of systems were done in C++ with CORBA or similar monstrosities?
Re: Why do we need "? extends" in Java
#10Why do we need Java?