🔤 Strings & Text
13 Java concepts, each explained step by step with real code, a common trap and practice questions.
- String immutabilityMethods return new Strings; the original never changes.
- The String poolLiterals are interned; new String creates a separate object.
- == vs equals()== compares references; equals compares content; equalsIgnoreCase.
- Core String methodslength, charAt, substring, indexOf, contains, replace, trim/strip, isBlank, repeat.
- Comparing StringscompareTo lexicographic order and case sensitivity.
- Splitting & joiningsplit takes a regex; String.join and Collectors.joining.
- StringBuilderMutable builder: append, insert, reverse, deleteCharAt; why it beats + in loops.
- StringBuilder vs StringBufferStringBuffer is synchronized and legacy.
- Formatting textString.format, formatted(), printf format specifiers %d %s %.2f %n.
- Text blocksTriple-quoted multi-line strings and incidental indentation.
- chars, Character & code pointsCharacter.isDigit/isLetter, toUpperCase, emoji as surrogate pairs.
- Converting to and from StringsString.valueOf, toString, Integer.parseInt, NumberFormatException.
- Null-safe string handling"literal".equals(x), Objects.equals, isEmpty vs isBlank.