SkyHog
Touchdown! Greaser!
- Joined
- Feb 23, 2005
- Messages
- 18,433
- Location
- Castle Rock, CO
- Display Name
Display name:
Everything Offends Me
I am having a bear of a time with what should be a really simple thing, and was wondering if any programmers could give advice on this.
In Java, I am trying to take a number, lets say 145, and add the individual digits together. I am taking the stupid backwards way in coverting to a string and trying to pull the chars out of it to do it, but I cannot find a way to convert a char to an int. I could convert the char to a string and then to an int, but that is even more backwards. Is there a way to pull a digit from a int like there is a way to pull a char from a string?
In Java, I am trying to take a number, lets say 145, and add the individual digits together. I am taking the stupid backwards way in coverting to a string and trying to pull the chars out of it to do it, but I cannot find a way to convert a char to an int. I could convert the char to a string and then to an int, but that is even more backwards. Is there a way to pull a digit from a int like there is a way to pull a char from a string?