问题
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.
回答1:
It seems very unlikely. They didn't make the cut for Java 7, as noted in the answer to Java 7 - Multiline strings
回答2:
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.
回答3:
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).
来源:https://stackoverflow.com/questions/11659225/any-future-plans-for-multiline-java-string