+ 1
Can I know why this java code prints 'b'. Please help if you can.
char x = 'A'; char y = 'a'; char z = 'B'; z += y-x; System.out.println(z); o/p : b
5 Answers
+ 11
Krishnanshu Dey If you feel too much calculation in less time & need of remembering ASCII values in it, then it can be done without knowing ASCII value & no calculation:
z='B' + 'a' - 'A'
probably 'B'-'A' will be returning 1, so char z='a'+1 that will be 'b'
happy coding
+ 2
Thanks all of you to sharing your knowledge with me. Now I can easily solve it.
+ 1
Thanks first to clear my doubt about this. So I have to remember those ASCII values. Is there any short trick to remember those values as I got this problem in challenge and it has only 30 sec to solve.