title: Java: Subtract '0' from char to get an int... why does this work?
body: <p>This works fine:</p>
  
  <pre><code>int foo = bar.charAt(1) - '0';
  </code></pre>
  
  <p>Yet this doesn't - because bar.charAt(x) returns a char:</p>
  
  <pre><code>int foo = bar.charAt(1);
  </code></pre>
  
  <p>It seems that subtracting '0' from the char is casting it to an integer.</p>
  
  <p>Why, or how,  does subtracting the string '0' (or is it a char?) convert another char in to an integer?</p>