You have declared the type a Node<? extends Number>
. What you assign to it is irrelevant.
As far as the compiler is concerned it could be any of the following:
Node<Integer>
Node<Float>
Node<Double>
- etc
And it has no way of knowing which type is the actual type.
You are trying to pass an (auto-boxed) Integer
, but the compiler can't know that the actual type can accept an Integer
.