25 lines
548 B
Plaintext
25 lines
548 B
Plaintext
If a string fits on a single line, without concatenation and escaped newlines, you should probably continue to use a string literal.
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
----
|
|
String question = """
|
|
What's the point, really?""";
|
|
----
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
----
|
|
String question = "What's the point, really?";
|
|
----
|
|
|
|
|
|
== See
|
|
|
|
* https://openjdk.java.net/jeps/368[JEP 368: Text Blocks] (Second Preview)
|
|
* https://cr.openjdk.java.net/~jlaskey/Strings/TextBlocksGuide_v9.html[Programmer's Guide To Text Blocks], by Jim Laskey and Stuart Marks
|
|
|
|
|