Strings
Table of contents
- Strings
- Mutable strings (
StringBuilder
andStringBuffer
) - Text blocks and multiline strings
- 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
- Puzzle (Hello Whirled)
- Puzzle (Line Printer)
- Puzzle (huh?)
- Puzzle (String Cheese)
- Puzzle (Classy Fire)
- Puzzle (What's my class?)
- Puzzle (What's my class, Take 2)
- Puzzle (No Pain, No Gain)