Are you familiar with numerical bases?
For example, '3' in base 10 is equal to 3, '101' in base 2 is equal to 5 in base 10, etc.
That's essentially what Character.digit
does -- it takes a character, a specified base, and returns the numerical value in base 10.
If you provide it with a value greater then the specified base (for example, Character.digit('3', 2);
, it'll just return -1, signifying an invalid value.