Commit ba4533d
committed
docs(generics): explain use of wildcards (?) for flexible type handling in Java
- Added documentation describing wildcards as placeholders for unknown types in generics.
- Clarified that wildcards allow looser type definitions and increase flexibility when exact type is not known at declaration.
- Highlighted practical use cases:
• Writing methods/classes that can work with a wider range of types.
• Allowing read-only access when modifying is unsafe (e.g., List<?>).
• Supporting inheritance scenarios where covariance/contravariance applies.
This improves conceptual understanding of how wildcards differ from concrete type parameters
and why they are essential for designing reusable, type-safe APIs.
Signed-off-by: https://github.com/Someshdiwan <[email protected]>1 parent e665f22 commit ba4533d
1 file changed
+8
-0
lines changedLines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
0 commit comments