How to Find Number of Digits in an Integer at Java
By Loop
public static int countDigitsInt(int input) {
int count = 0;
while (input != 0) {
input /= 10;
++count;
}
return count;
}
By Math
System.out.println(((int) (Math.log10(input))...
eunhanlee.hashnode.dev1 min read