So what i understand is that if for example i have an int a = 49 and want to find out the ASCII equivalent to it, all i need to do is:
int a = 49; System.out.println((char)a); which has the Output: 1.
But how can i do this reversed? So lets say i have int a = 1 and i want the output to be 49?
I have already tried stuff like:
int a = 1; System.out.println ((char)a); But the output here is "." instead of 49.
1ascharwhich means'1'.ato move from'0'characteraamount of times. For instance'0' + 0would return index of'0'.'0' + 1would return index of'1'. All you need to do with that index is convert it back tochar. So you can write something likeint a = 1; char ch = (char)('0'+a);.char ch = Character.forDigit(a, 10);.