The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
February 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Converting a char to its ASCII value in Java

Posted by Art Metzer on January 04, 2002 at 3:38 PM

> I am trying to convert chars to the ascii number, perform some
> math, and convert the result back to char. However, the use
> of Character.getNumericValue('A') returns 10, not 65 as expected.

> How can I do this?

From http://www.rgagnon.com/javadetails/java-0004.html:
char c = 'A';
int i = (int) c;
System.out.println( i );

Art M.



Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us