in Java, this is how you can separate digits from numbers and store them in an Array.
public static void main(String[] args) {
System.out.println("Digits Array:: "+Arrays.toString(getNumberArr(1100)));
}
private static Integer[] getNumberArr(int number) {
//will get the total number of digits in the number
int temp = number;
int counter = 0;
while (temp > 0) {
temp /= 10;
counter++;
}
//reset the temp
temp = number;
// make an array
int modulo; //modulo is equivalent to single digit of the number.
Integer[] numberArr = new Integer[counter];
for (int i = counter - 1; i >= 0; i--) {
modulo = temp % 10;
numberArr[i] = modulo;
temp /= 10;
}
return numberArr;
}
Output:
Digits Array:: [1, 1, 0, 0]