Java Master Tutorial chapters
  1. 01Introduction & JVM Architecture
  2. 02Data Types, Variables & Type Conversion
  3. 03Operators & Control Flow
  4. 04Object-Oriented Programming (OOP) Core
  5. 05Inheritance & Polymorphism
  6. 06Abstraction & Interfaces
  7. 07Memory Management & Garbage Collection
  8. 08Strings & String Pool
  9. 09Exception Handling
  10. 10Java Collections Framework
  11. 11Multithreading & Concurrency
  12. 12Java 8 Features & Streams

Chapter 8

Strings & String Pool

3 topics in 1 parts

Key ideas

Input Size (n) → Time (T) ↑ O(1) O(log n) O(n) O(n log n) O(n²) O(2ⁿ)
Strings & String Pool
ComponentJVM StackJVM Heap Space
Storage ContentMethod frames, primitive local variables, object referencesAll created object instances and arrays
Thread SafetyThread-isolated (strictly private to thread)Globally shared across all application threads
LifecycleCreated on method entry, popped on returnManaged by Garbage Collector (G1 / ZGC)
Memory ErrorStackOverflowError (deep recursion)OutOfMemoryError: Java heap space

All 3 topics in Strings & String Pool

  1. Strings

    • String Constant Pool (SCP)
    • String vs StringBuilder vs StringBuffer
    • == vs .equals() & hashCode() Contract