File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Unicode Character Values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Unicode Character Values" Watch "Unicode Character Values" New topic

Unicode Character Values

Aran Winters

Joined: Nov 23, 2003
Posts: 11

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.

Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
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.



Java API Documentation
The Java Tutorial
Nick George
Ranch Hand

Joined: Apr 04, 2004
Posts: 815
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
Aran Winters

Joined: Nov 23, 2003
Posts: 11
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

I agree. Here's the link:
subject: Unicode Character Values
It's not a secret anymore!