aspose file tools*
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
Author

Converting an INT to a CHAR ?

Kristian Andersson
Greenhorn

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
Bartender

Joined: Aug 20, 2001
Posts: 1817

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
Sheriff

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 asciitable.com for ascii character info.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
 
 
subject: Converting an INT to a CHAR ?