Reputation: 21674
In the spirit of this question: https://stackoverflow.com/questions/1886966/java-string-declaration-occupying-multiple-lines
will there be any plans in any future version of Java to allow string continuation in the java scource?
String haveUeverSeenLorem =
"Lorem ipsum dolor sit amet, \
consectetur adipisicing elit, \
sed do eiusmod tempor incididunt \
ut labore et dolore magna aliqua.";
Either one way or another, e.g. like the above example.
Upvotes: 8
Views: 3779
Reputation: 3194
Update April 2020
The JEP 326: Raw String Literals was withdrawn and is replaced by
JEP 368: Text Blocks (Second Preview).
This feature is released as a preview language feature in Java 14.
The supported syntax is:
String json = """
{
"id": 10,
"name": "Joe",
"birthday": "1970-01-01"
}
""";
"""
(fat delimiters) are used as delimiters for multiline strings.
Upvotes: 1
Reputation: 9497
Update January 2018:
Have a look at JEP 326: Raw String Literals.
The planned syntax will be:
String haveUeverSeenLorem = `Lorem ipsum dolor sit amet,
consectetur adipisicing elit,
sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua.`;
Maybe it will be integrated in the next version of Java (Java 11 in September 2018 would be great).
Upvotes: 4
Reputation: 328835
It was proposed for inclusion in Java 7 but was rejected.
It was proposed again for Java 8 but did not make it to the final version.
Java 9's JEP 213: Milling Project Coin does not include anything regarding multine strings either.
Upvotes: 10
Reputation: 8885
It seems very unlikely. They didn't make the cut for Java 7, as noted in the answer to Java 7 - Multiline strings
Upvotes: 4