Any Future Plans for Multiline Java String

梦想与她 提交于 2019-12-23 08:35:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!