8

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.

Community
  • 1
  • 1
Blessed Geek
  • 21,058
  • 23
  • 106
  • 176

4 Answers4

10

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.

assylias
  • 321,522
  • 82
  • 660
  • 783
4

It seems very unlikely. They didn't make the cut for Java 7, as noted in the answer to Java 7 - Multiline strings

Community
  • 1
  • 1
John Watts
  • 8,717
  • 1
  • 31
  • 35
  • Unlikely - meaning they will not be considering it seriously at all anytime in the future? Even after gosling has left? – Blessed Geek Jul 26 '12 at 01:27
  • Proposed and rejected. According to assylias' answer, it happened again in Java 8. As far as I know, no one said never. As far as I know "we will never seriously consider this". Simply, relative to other things they (and I don't know who they are because I don't understand the JCP) decided not to do it so far. I only add "unlikely" because all things being equal I find that a proposal that is repeatedly rejected is likely to continue to be rejected for the same reasons in the future. That's just my opinion, though. – John Watts Jul 26 '12 at 11:29
4

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).

Jmini
  • 9,189
  • 2
  • 55
  • 77
1

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.

pero_hero
  • 2,881
  • 3
  • 10
  • 24