I am new to generics, so bear with me.
I was sure I understood what this statement meant:
List<? extends Number> nums = new ArrayList<>();
To me, it means List will accept any objects added to the list which are of the Number
class or extend the Number
class.
So when I added a double to the list, I expected it to work
List<? extends Number> nums = new ArrayList<>();
nums.add(3.14);
However, I get the error List cannot be applied to double