Split digit in java

java
Below sample program can be used to split number into digits. Here we are using a 4 digit number to do the same.
class Split
{
public static void main(String args[])
{
int a=1234,r=0;
while(a!=0)
{
r=a%10;
a=a/10;
System.out.println(r+"");
}
}
}

Output:

Comments

Popular posts from this blog

Hamming code in java

Why companies hiring Interns, build their BRAND faster?

Bully Algorithm in Java program