title: How can I convert a char to int in Java?
body: <p>(I'm new at Java programming)</p>
  
  <p>I have for example:</p>
  
  <pre><code>char x = '9';
  </code></pre>
  
  <p>and I need to get the number in the apostrophes, the digit 9 itself.
  I tried to do the following,</p>
  
  <pre><code>char x = 9;
  int y = (int)(x);
  </code></pre>
  
  <p>but it didn't work.</p>
  
  <p>So what should I do to get the digit in the apostrophes?</p>