0

How does one go about converting an integer like

int keycode = 65;

into

String keycode = "a"?

Thanks everyone, I know how to do it vice-versa, I've searched all over and have not found a solution.

Neil Derno
  • 77
  • 2
  • 13

3 Answers3

1

You can use this to do your operation. Since You have 0 to 255 ASCII values, You need to validate it before manipulating.

    int value = 65;
    if (value >= 0 && value <= 255) {
        char character = (char) value;
    }
ashokramcse
  • 2,841
  • 2
  • 19
  • 41
  • Strictly speaking ASCII is 0-127. – Dunes Nov 27 '14 at 11:53
  • @Dunes I incluedes Extended ASCII Codes too. – ashokramcse Nov 27 '14 at 11:54
  • Extended ASCII is not ASCII. There are an hoards of character encodings that that are identical to to ASCII below 128, but have radically different characters for 128-255. Compare ISO/IEC 8859-1 (Latin-1/extended ASCII) and ISO/IEC 8859-8 (Latin/Hebrew). We don't which country OP is from, so you shouldn't make assumptions about which character set might be in use. – Dunes Nov 27 '14 at 12:12
0
 Character.toString((char) keycode);
Bruce
  • 8,609
  • 8
  • 54
  • 83
0

I think this will do:

String str = String.valueOf((char)keycode);
Sarthak Mittal
  • 5,794
  • 2
  • 24
  • 44