title: Converting characters to integers in Java
body: <p>Can someone please explain to me what is going on here:</p>
  
  <pre><code>char c = '+';
  int i = (int)c;
  System.out.println("i: " + i + " ch: " + Character.getNumericValue(c));
  </code></pre>
  
  <p>This prints <code>i: 43 ch:-1</code>. Does that mean I have to rely on primitive conversions to convert <code>char</code> to <code>int</code>? So how can I convert a <code>Character</code> to <code>Integer</code>?</p>
  
  <p><strong>Edit:</strong> Yes I know <code>Character.getNumericValue</code> returns <code>-1</code> if it is not a numeric value and that makes sense to me. The question is: why does doing primitive conversions return <code>43</code>?</p>
  
  <p><strong>Edit2:</strong> <code>43</code> is the ASCII for <code>+</code>, but I would expect the cast to not succeed just like <code>getNumericValue</code> did not succeed. Otherwise that means there are two semantic equivalent ways to perform the same operation but with different results?</p>