java separate integer into digits code example
Example 1: how to store a 6 digit number as 6 separate integers
int number; // = some int
while (number > 0) {
print( number % 10);
number = number / 10;
}
Example 2: how to separate a number into digits java
public static void main(String[] args) {
int num=1020; // int number
while (num > 0) {
System.out.println( num % 10);
num = num / 10;
}
}