made a bit simple to understand.

just changed Character.digit() to Character.getNumericValue();