Rajiv Rai wrote:
The output for the above code is as follows
15
0
-41
How does -41 come out as result of third print statement?
15 - I don't understand that. Hope someone might comment.
0 because Character.getNumericValue() function extracts the integer from the character. So '0' is of course zero.
'0' is ascii value 48 decimal (or 0x30) - see
http://www.asciitable.com/
therefore 7 - 48 = -41
But I am puzzled with the 15 result.
EDIT
Just looked again at ascii chart. decimal 102 is character f. In hex this can be converted to decimal 15 - so there is that answer.