title: What does String.substring exactly do in Java?
body: <p>I always thought if I do <code>String s = "Hello World".substring(0, 5)</code>, then I just get a new string <code>s = "Hello"</code>. This is also documented in the Java API doc: <em>"Returns a new string that is a substring of this string"</em>.</p>
  
  <p>But when I saw the following two links, I began to doubt.</p>
  
  <p><em><a href="https://stackoverflow.com/questions/390703/what-is-the-purpose-of-the-expression-new-string-in-java">What is the purpose of the expression &quot;new String(...)&quot; in Java?</a></em></p>
  
  <p><a href="http://kjetilod.blogspot.co.uk/2008/09/string-constructor-considered-useless.html" rel="nofollow noreferrer">String constructor considered useless turns out to be useful after all</a></p>
  
  <p>Basically, they say if I use <code>String s = "Hello World".subString(0, 5)</code>, I still get a String which holds "Hello World"'s char array. </p>
  
  <p>Why? Does Java really implement substring in this way? Why in this way? Why not just return a brand new shorter substring?</p>