Wildcard (Java): Difference between revisions

Content deleted Content added
Cydebot (talk | contribs)
m Robot - Speedily moving category Java programming language to Category:Java (programming language) per CFDS.
Ptalb (talk | contribs)
Wildcard as parameter type: missing initialization + other example of type error
Line 22:
}
...
Generic<?> wildcardReference = new Generic<>();
UpperBound ub = wildcardReference.read(); // Object would also be OK
wildcardReference.write(new Object()); // type error
wildcardReference.write(new UpperBound()); // type error
((Generic<UpperBound>)wildcardReference).write(new UpperBound()); // OK
</source>