This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Variable convertion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Variable convertion" Watch "Variable convertion" New topic

Variable convertion

Marky Mark

Joined: Nov 12, 2003
Posts: 4
Hello, i was wondering if it is possilbe to convert an Integer to a charachter?
ie - so '1' = 'a'
and '2' = 'b' and so on
i know this much : number=integer.parseInt(number); < this , i think,
converts a srting to an int, i think its something like this
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
Because an int to a char is considered a narrowing conversion you need to cast the int to a char.
int i = 65;
char itoc = (char)i;
// prints A
Going the other way is easier because you dont need to cast an a char to an int, as it is conseidered a widening conversion.
char a = 'A';
int atoi = a;
// prints 65
hope that helps

Don't get me started about those stupid light bulbs.
subject: Variable convertion
Similar Threads
how to clear the stack
How to remove the record number from GUI
How many classes r included in ur design ( Client Side ) ?
Olympic 2008
mso-number-format question