How can I separate the digits of an int number in Java
If I have a number 2500, I want the output to be: 2, 5, 0, 0. How can I separate the numbers into digits?
We can easily split integers into digits java.
public static void main(String[] args) {
int num=1020; // int number
while (num > 0) {
System.out.println( num );
num = num / 10;
}
}