I have the following code:
ArrayList<? extends IValues> valuesList
IValues is an interface.
The list is filled with classes/objects that implement the IValues interface.
I do understand the the concept of every object in this list having to fulfill the contract laid down by the interface they implement.
Why doesn't the java language do this like this:
ArrayList<? implements IValues> valuesList
? This would be much clearer to the user, wouldn't it?
That's how Generics are designed in Java.
Note that the super keyword is used here, as well, but it has totally different meaning than outside Generics.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With