I just started learning Java (two months and counting), and I still have lots of questions and a whole lot to learn. Right now I want to use the
Scanner class to "divide" an integer into its digits. I'll explain myself better with an example:
I request the user to type a four-digit integer, say
8919. What I want to do is to use the
Scanner class to divide that integer and to assign each one of its digits to a variable; i.e.
a = 8,
b = 9,
c = 1 and
d = 9.
I positively know that it can be done and that the
Scanner class is the way to go. I just don't know how to properly use it. Can a noob in need get some help here? Thanks!
EDIT:The suggestion that has been made does not match my specific question. In that thread the class
Scanner is not used to separate the integer into digits. I specified i wanted to use the
Scannerclass because many different methods used there are still way beyond my level. Anyway, there are lots of interesting ideas in that thread that i hope i will be able to use later, so thanks anyway.