There is a much simpler way to find out whether a
char represents a digit or 0.
And don’t write
if (...) return true; else return false;Yes, you can do arithmetic with
chars, because, contrary to popular belief they are not letters. They are numbers. '0' is stored as (I think) 0x30 = 48decimal. '0' to '9' are a consecutive sequence, so you can use that trick.
There is also a method in the
Character class which does the same thing.