Link

Strings

Table of contents

  1. Strings
  2. Mutable strings (StringBuilder and StringBuffer)
  3. Text blocks and multiline strings
  4. Does Java supports string interpolation?

Strings

🚧 Pending 🚧

Mutable strings (StringBuilder and StringBuffer)

🚧 Pending 🚧

Text blocks and multiline strings

As of Java 15, Java will start supporting text block, also referred to as multiline Strings, defined by JEP-378. The text block will be defined by the Java language specification 3.10.6, currently available as preview.

⚠ Require Java 15 (or Java 14 in preview mode)!!
package demo;

public class App {
  public static void main( String[] args ) {
    String s = """
               “This is the day upon which
                we are reminded of what we
                are on the other 364.”
                —Mark Twain
               """;
    System.out.println(s);
  }
}

The above example will print.

“This is the day upon which
 we are reminded of what we
 are on the other 364.”
 —Mark Twain

Note how the second, third and fourth lines are indented by one space, preserving the formatting.

Does Java supports string interpolation?

No.

🚧 Pending 🚧

Table of contents