title: java substring not working as expected
body: <p>I'm trying to use substring function in java, but it keeps throwing an error, I want to know why ? the code seems to be good logically speaking but why it is throwing this error </p>
  
  <pre><code>Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -1
  </code></pre>
  
  <p>What I've read in the documentation substring takes 2 parameter </p>
  
  <pre><code>substring(whereIwantToStart,howManyCharactersToshow)
  </code></pre>
  
  <p>below is my code </p>
  
  <pre><code>    String test = "160994";
      System.out.println(test.substring(2,1)); //output should be 09 why error?
  </code></pre>
  
  <p>Can someone explain me what is wrong ? please I need explanation. Thanks :)</p>