PDA

View Full Version : [SOLVED] Java: convert a unicode value into a char



NovaAesa
March 12th, 2008, 02:22 AM
Say I have an integer value and want to convert it into a char, what's the best way of doing this? I have looked through the javadocs for the Character class but couldn't come up with anything.

Could someone point me in the right direction?

amingv
March 12th, 2008, 05:39 AM
You mean something like this?



class Main {
public static void main (String[] args) {
int foo = (int)'A';
char bar = (char)65;
System.out.println (foo);
System.out.println (bar);
}
}

NovaAesa
March 12th, 2008, 06:25 AM
Thank you! That was exactly what I was looking for.