Computer Science Canada

Java String from ASCII value

Author:  Martin [ Thu Jul 21, 2005 8:16 pm ]
Post subject:  Java String from ASCII value

How do I create a string containing the character represented by an int ASCII value?
I've tried casting from int to char, but apparently that doesn't work.
ie.
x = 97;
System.out.println (ASCIIString(x)); //print 'a'

Author:  Martin [ Thu Jul 21, 2005 8:22 pm ]
Post subject: 

Figured it out. Java is gross.

Conversion from an int to a String.

int x = 97;
System.out.println (((char) x) + "");

Author:  rizzix [ Thu Jul 21, 2005 8:28 pm ]
Post subject: 

eh? why not simply...
Java:
char a = 97;
System.out.println(a);


oh, but if you want a String yea just concatenate it with +""
or...
Java:
String a = new String(new char[]{97});


or best...
Java:
String a = Character.toString(97);


: