I just want to know if there\'s a better solution to parse a number from a character in a string (assuming that we know that the character at index n is a number).
By simply subtracting by char '0'(zero) a char (of digit '0' to '9') can be converted into int(0 to 9), e.g., '5'-'0' gives int 5.
String str = "123"; int a=str.charAt(1)-'0';