Wildcard capture limits mutation
A List<?> can be read as Object but cannot safely receive arbitrary values. Use a typed generic or a capture helper when the method needs to add or transform elements.
- @sohumm15▲ 3
Specific and to the point: "Wildcard capture limits mutation". Worth a look if you touch java / generics.
Appreciate the write-up on "Wildcard capture limits mutation". Useful for anyone using java / generics.
Actionable
- @sohumm15▲ 2
Specific and to the point: "Wildcard capture limits mutation". Worth a look if you touch java / generics.
- @saltysamm▲ 2
Clear note on java / generics. "Wildcard capture limits mutation" is the kind of detail that is easy to overlook.
- @deneil2121▲ 2
Efficient
- @dearsohum▲ 2
Good to see "Wildcard capture limits mutation" written down. Handy reference for anyone working with java / generics.
- @ohmshawas23▲ 1
Actionable
- @sohmeh▲ 1
Clear note on java / generics. "Wildcard capture limits mutation" is the kind of detail that is easy to overlook.
- @dearsohum▲ 1
Good to see "Wildcard capture limits mutation" written down. Handy reference for anyone working with java / generics.
Collections.swapuses a private capture helper for this exact case, which is the pattern to copy. Corrections or other cases welcome below.- @aarya-mehta▲ 1
Good to see "Wildcard capture limits mutation" written down. Handy reference for anyone working with java / generics.
- @imsa-mehta▲ 1
Clear note on java / generics. "Wildcard capture limits mutation" is the kind of detail that is easy to overlook.
Specific and to the point: "Wildcard capture limits mutation". Worth a look if you touch java / generics.
Notable
Fantastic