Study 1Z0-831 Java 25 Collections, Ordering, and Generic Bounds: key concepts, common traps, and exam decision cues.
Collection questions look familiar, which is why they are dangerous. The trap is often an API contract you thought you remembered.
| Requirement | Strongest first fit |
|---|---|
| immutable factory result | List.of(...), Set.of(...), Map.of(...) |
| fixed-size array-backed list | Arrays.asList(...) |
| producer source | ? extends T |
| consumer sink | ? super T |
| order-sensitive reasoning | encounter order and collection type both matter |
| Trap | Better rule |
|---|---|
| assuming all read-only looking collections behave the same | fixed-size and unmodifiable are different contract families |
| treating generic types as covariant like arrays | generic invariance still applies |
| guessing wildcard direction | use PECS explicitly |