KITFORMA · EDITORIAL GUIDE
Why can I read a List<? extends Number> but not add an Integer to it?
KitForma editorial guide. The unknown element type might be a more specific subtype than Integer. Knowing the upper bound is enough to read, but not to manufacture a valid element.
Step-by-step guidance
List<Number> output = new ArrayList<>();, copy the source values and append the new integer there. If it only writes integers to a caller-owned collection, declare a lower-bounded destination parameter. Avoid unchecked casts: a Double-only source is a useful counterexample showing why the cast is unsafe.
Compile with unchecked warnings enabled and test a source whose element type differs from your appended value. Copying the container does not copy mutable elements deeply; ownership of the contained objects still needs a separate rule.Sources and verification
Sources checked:
Scope: This editorial guide is based on the cited sources and tool behavior. A forum question or a query observed for our site does not establish market search volume, low competition, guaranteed rankings or inadequate answers elsewhere.
This starter guide was prepared by KitForma with AI assistance. It is not presented as a real member question or an independent user review. Check the sources and the result with your own file; report corrections in the discussion.