title: Why doesn't calling a substring using the length of the string as the beginning index throw an OutOfBoundsException?
body: <p>When was testing some code, I noticed that the substring method wouldn't throw an exception if the index I used was equal to the length of the string. For example:</p>
  <pre><code>String s = &quot;holy&quot;;
  System.out.println(s.substring(4));
  </code></pre>
  <p>The output would return nothing, but it wouldn't throw an exception. But if I tried to call:</p>
  <pre><code>String s = &quot;holy&quot;;
  System.out.println(s.substring(5));
  </code></pre>
  <p>It would throw an IndexOutOfBoundsException. I read the Javadoc for the method and it says</p>
  <blockquote>
  <p>if beginIndex is negative or larger than the length of this String object.</p>
  </blockquote>
  <p>Anyone know why it allows for the beginning index to be equal to the string length?</p>