28th April 2020, 3:43 PM
charAt equates to an integer (ASCII codes). See here for more information: https://www.cs.cmu.edu/~pattis/15-1XX/co...ascii.html.
Therefore, parseInt() won't throw an error. If you want to test if it's not a number, try this:
Therefore, parseInt() won't throw an error. If you want to test if it's not a number, try this:
Code:
char thisChar = ssn.charAt(i);
if (thisChar < 48 || thisChar > 57) {
// handle error
}