title: Does concatenating strings in Java always lead to new strings being created in memory?
body: <p>I have a long string that doesn't fit the width of the screen. For eg. </p>
  
  <pre><code>String longString = "This string is very long. It does not fit the width of the screen. So you have to scroll horizontally to read the whole string. This is very inconvenient indeed.";
  </code></pre>
  
  <p>To make it easier to read, I thought of writing it this way -  </p>
  
  <pre><code>String longString = "This string is very long." + 
                      "It does not fit the width of the screen." +
                      "So you have to scroll horizontally" +
                      "to read the whole string." +
                      "This is very inconvenient indeed.";
  </code></pre>
  
  <p>However, I realized that the second way uses string concatenation and will create 5 new strings in memory and this might lead to a performance hit. Is this the case? Or would the compiler be smart enough to figure out that all I need is really a single string? How could I avoid doing this? </p>