devxlogo

ASCII Value Conversions

ASCII Value Conversions

Question:
How can I convert an integer ascii representationof a number to its character equivalent in astring form. For example

A= 72 

What procedure will take in int 72 and returnstring “A”

Answer:
The simplest way to accomplish this is totypecast the int to a char and convert thatchar to a String. You have several choiceswhen it comes to converting a char toa string, but perhaps the simplest way toaccomplish what you want is:

int a = 72;Character aChar;String aString;aChar = new Character((char)a);aString = aChar.toString();

devx-admin

Share the Post: