I am trying to convert between integers and characters for the purpose of writing a class to sort strings alphabetically.
I found a method to convert from character to integer (--> java.lang.Character.getNumericValue() <--), but have not been able to find a method which allows be to provide an integer argument returning a character (according to the Unicode value).
I have looked over the methods in the java.lang.Character and java.lang.Integer classes, but was not successful in finding what I need.
If someone could point me in the right direction I would appreciate it.
I'm not quite clear on what you are attempting to do. What kind of conversion are you trying to do? There are several kinds. For example the character 'A' has an underlying numerical value (I'm not sure what it is). Similarly all characters have a numerical value (as far as I know). On the other hand, you may be attempting to take the character '1' and get the integer value 1. I am sure that someone else can dream up yet another definition of "convert between integers and characters". Can you please give a more detailed description of what you want? Perhaps some examples to illustrate the expected input and output for this portion of your program will help clear things up.
If I understand you correctly, it's alot easier than you think
'A' == (char) 65 (int)'A' == 65
I've heard it takes forever to grow a woman from the ground
Joined: Nov 23, 2003
Sorry I wasn't more clear,
I was trying to convert single chars ('A'), into their underlying numerical values. I think the unicode values are offset differently, but the second reply still does the trick. Thanks for all the responses.