PDA

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


NovaAesa
March 11th, 2008, 09:22 PM
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, 12: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, 01:25 AM
Thank you! That was exactly what I was looking for.