title: Test if char after minus is a number
body: <p>I have this String <code>9 $ -2 -</code>. I want to test if the next of <code>-</code> is a number.</p>
  
  <pre><code>if (ch == '-') {
      if (ch != input.length() - 1) {
          char next = input.charAt(j + 1);
          if ((next &gt;= '0' &amp;&amp; next &lt;= '9') || next == '.')
              temp = temp + ch;
      }
  }
  </code></pre>
  
  <p>I can't find how to do it while if <code>-</code> may be in the last of String</p>
  
  <pre><code>Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 8
      at java.lang.String.charAt(String.java:658)
      at ParsePost.doParse(ParsePost.java:24)
      at InfixApp.main(InfixApp.java:20)
  </code></pre>