Generics : List<? extends Animal> is same as List<Animal>?

Posted by peakit on Stack Overflow See other posts from Stack Overflow or by peakit
Published on 2010-04-04T18:01:29Z Indexed on 2010/04/04 18:03 UTC
Read the original article Hit count: 201

Filed under:
|
|

Hi,

I am just trying to understand the extends keyword in Java Generics.

List<? extends Animal> means we can stuff any object in the List which IS A Animal

then won't the following also mean the same thing:

List<Animal>

Can someone help me know the difference between the above two? To me extends just sound redundant here.

Thanks!

© Stack Overflow or respective owner

Related posts about java

Related posts about generics