atoi in java using charAt
<p>I know that one solution to do this is the following:</p>

<pre><code> String tmp = "12345";
      int result = 0;
      for (int i =0; i &lt; tmp.length(); i++){
          char digit = (char)(tmp.charAt(i) - '0');
          result += (digit * Math.pow(10, (tmp.length() - i - 1)));

      }

      System.out.println(result);
</code></pre>

<p>What I don't understand is why is:</p>

<pre><code>char digit = (char)(tmp.charAt(i) - '0');
</code></pre>

<p>How can this convert into a digit?</p>
