~/talk

java.lang.String Catechism

Talkat Joker 2014 · 2014-10-20..10-21· [java]
slides:none on file

Machine benchmarks with JMH show naive concatenation can incur ~30x slowdown versus StringBuilder because the compiler/JIT rewrites concatenation but bails out on side effects; logging benefits from Supplier lambdas but explicit guards remain fastest. Strings store a final char[] and cached hash (zero is the “not computed” sentinel), so substring retains big char[] causing OOM in older JDKs (JDK8 copies), intern() hits a fixed VM string table and is far slower than a custom interner, and HashMap collisions enable DoS mitigated by Java 8 treeification. Beware regex catastrophic backtracking; Boyer‑Moore beats indexOf on huge texts.

AI-written summary · about

  1. 0:00Introduction and disclaimer
  2. 1:14Why strings matter
  3. 3:42String internals
  4. 6:29String concatenation costs
  5. 9:21StringBuilder optimization
  6. 11:30Integer to string vs concat
  7. 13:14Side effects in concatenation
  8. 15:00Lazy logging with lambdas
  9. 18:10String hash code internals
  10. 20:19HashMap performance pitfalls
  11. 26:16Substring memory issues
  12. 29:12Deduplication vs interning
  13. 33:47String deduplication in JVM
  14. 36:37String comparison optimizations
  15. 40:28String split performance
  16. 42:40Regex catastrophic backtracking
  17. 45:07CharAt vs char array access
  18. 48:19String search algorithms
  19. 52:15Conclusion and Q&A
~/search
type to search 8,222 conferences, 162,397 speakers and 219,688 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
← →
on a talk: 5 seconds back / forward
0–9
on a talk: jump to 0%–90% of the recording
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.