Java

Strings

16 lessons in this section of the Java tutorial. Work through them in order, or jump to the one you need.

  1. 1.String Class

    String is one of the most fundamental classes in Java — used in virtually every program, yet deeply misunderstood by many developers.

  2. 2.String Pool

    The string pool (also called the string intern pool or string constant pool) is a special memory region maintained by the JVM that stores a single copy of each unique…

  3. 3.Immutable String

    String immutability is the most important design decision in Java's String class.

  4. 4.Mutable String

    Java provides two mutable string classes for scenarios where String's immutability would be inefficient: StringBuilder and StringBuffer.

  5. 5.String Methods

    The String class provides over 60 methods covering character inspection, searching, comparison, transformation, splitting, joining, formatting, and encoding.

  6. 6.String Comparison

    Comparing strings in Java requires choosing the right method for the right purpose.

  7. 7.equals() vs ==

    The == operator and the equals() method serve fundamentally different purposes in Java.

  8. 8.StringBuffer

    StringBuffer is a mutable sequence of characters that can be modified after creation.

  9. 9.StringBuilder

    StringBuilder is a mutable sequence of characters introduced in Java 5 as the preferred alternative to StringBuffer for single-threaded use.

  10. 10.StringTokenizer

    StringTokenizer is a legacy Java class that breaks a string into tokens — substrings separated by delimiter characters.

  11. 11.StringJoiner

    StringJoiner is a utility class introduced in Java 8 that builds a sequence of strings separated by a delimiter, with optional prefix and suffix.

  12. 12.Text Blocks

    Text blocks are a Java 15 feature (previewed in Java 13 and 14) that provide multi-line string literals without manual escape sequences and concatenation.

  13. 13.Unicode Handling

    Java was designed from the ground up for Unicode.

  14. 14.Regular Expressions

    Regular expressions are a domain-specific language for describing patterns in text.

  15. 15.Pattern Class

    The Pattern class in java.util.regex is the compiled representation of a regular expression.

  16. 16.Matcher Class

    The Matcher class (java.util.regex.Matcher) is the engine that applies a compiled regular expression Pattern to a specific input string and performs matching operations.