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 Converting an INT to a CHAR ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Converting an INT to a CHAR ?" Watch "Converting an INT to a CHAR ?" New topic

Converting an INT to a CHAR ?

Kristian Andersson

Joined: Apr 23, 2004
Posts: 7
I'm trying to find out what ASCII-numbers are equalent to the letters:
"c", "o", "m". Perhaps not the easiest way, but I set up this code:

I knew it wouldn't work. Somehow, I need to convert the int to a char, or whatever. Almost like the Integer-thing, but not quite. (And yes, I don't know the exact words or terms for "it". If anyone wants to explain it to me - go ahead.)
And by the way. If it would've worked, then I would've counted every printout on the screen until I stumbled upon the desired letters.
[ May 10, 2004: Message edited by: Kristian Andersson ]
Joel McNary

Joined: Aug 20, 2001
Posts: 1824

Your code is fine as it is, you just need to explicitly cast the int to a char (Since an int is larger than a char, the compiler thinks that you made a mistake. Explicit casts are ways of telling the compiler "I know what I'm doing ... I think )

BTW, the last series of lines will do what you are looking for without having to search the printout.

Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
I'm trying to find out what ASCII-numbers are equalent to the letters:
"c", "o", "m".

If you're not necessarily looking for a code-based solution, I frequently peek at for ascii character info.

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
I agree. Here's the link:
subject: Converting an INT to a CHAR ?