Phase IX
Text and Types
String behaviour, text construction, generic types, and wildcards.
Explain String immutability and pooling, use the main String operations, and build changing text with StringBuilder. Then define generic classes and methods, trace type erasure, and use wildcards to express safe read and write boundaries.
When you finish this phase you can
- State when String literals and explicitly interned values use the String pool
- Explain why String had to be immutable before the pool could exist
- Measure the cost of joining text with + and fix it with StringBuilder
- Write a generic class and a generic method, and bound a type parameter
- Explain type erasure and the run-time operations it prevents
- 9.1Strings: The Pool and ImmutabilityExplain String immutability, literal pooling, object identity, and why text content must be compared with equals rather than ==.The String Pool
- 9.2String Methods and StringBuilderUse the String methods needed for search, slicing, cleanup, and comparison, then build changing text efficiently with StringBuilder.StringBuilder
- 9.3GenericsDeclare generic classes and methods, apply type bounds, and explain how compile-time type checks replace unsafe Object casts.GenericsType erasure
- 9.4Wildcards: `extends` and `super`Explain generic invariance and use unbounded, extends, and super wildcards without giving up type safety.WildcardsPECS