Re: Convert from int to char



Mocha_Java wrote:
Okay, so i have a dilemma. I have a int variable called rank that
stores integers (obviously). however, i need to display these values as
chars in another method. casting dosent help because it just converts
the integer into the unicode character which isn't the same as the
number.

heres a snippet of the problem:

char r; // as you can see, its gets pretty
repetitive and boring
if (rank == 2)
r = '2';
if (rank == 3)
r = '3';
if (rank == 4)
r = '4';

....
return r;


is there a trick to make my int number the equivalent char number?

Roedy has an online applet, on his website, that will let you select the from and to Object types and offer the available Java statement to do the conversion.

http://mindprod.com/applets/converter.html

You can also download it also.

--
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
.



Relevant Pages

  • Re: Convert from int to char
    ... stores integers. ... chars in another method. ... casting dosent help because it just converts ...
    (comp.lang.java.help)
  • Convert from int to char
    ... I have a int variable called rank that ... stores integers. ... i need to display these values as ... chars in another method. ...
    (comp.lang.java.help)
  • Re: Convert from int to char
    ... chars in another method. ... a character string, to display in a textbox or the like. ...
    (comp.lang.java.help)
  • ranking texts against a white list
    ... I have many small texts (200-1000 chars), I have a white list, I ... have to evaluate any text with its relevancy against the word list. ... yes --> rank = 1 ...
    (comp.lang.perl.misc)