Skip to content
CodeWiki
Practice
Paths
Tracks
Cheatsheets
Playground
Glossary
AI era
Search
⌘K
English
English
Chinese
Practice
Paths
Tracks
Cheatsheets
Playground
Glossary
AI era
English
English
Chinese
Practice
/
Quiz
/
Java
/
Wildcards and PECS
Why can a private `<T> void swap(List<T> values, ...)` helper accept a `List<?>` from a p…
from Wildcards and PECS
Java 25 LTS
advanced
1 min
Why can a private `<T> void swap(List<T> values, ...)` helper accept a `List<?>` from a public method?
Invocation inference names the one captured element type for that helper call.
The JVM inspects every list element and chooses their common runtime class.
Every unbounded wildcard is replaced with Object before source checking.
The helper silently performs an unchecked cast.
Check
Ask AI about this kata
Report an error
next kata
What does this program print?
Predict the output
A new version is available
Reload