Logo

Programming-Idioms

  • Scheme
String s = """
This is a very long string which needs
to wrap across multiple lines because
otherwise my code is unreadable.
""";

Available since Java 15
String s = "This is a very long string which needs \n" +
           "to wrap across multiple lines because \n" +
           "otherwise my code is unreadable.";
import java.util.Formatter;
String s;
StringBuilder b = new StringBuilder();
Formatter f = new Formatter(b);
f.format("line 1%n");
f.format("line 2%n");
f.format("line 3%n");
f.format("line 4");
f.flush();
s = b.toString();
import static java.lang.System.lineSeparator;
String s, n = lineSeparator();
s = "line 1" + n;
s = s + "line 2" + n;
s = s + "line 3" + n;
s = s + "line 4";
(define s "This is my multi-line literal.
Line number two!
  This line starts with two spaces.")
s : String := "Will this compile? " &
     "Oh yes it will";

I'm assuming this is what is meant by "consisting in several lines of text."

Use New_Line for line feeds.

New implementation...