Check out example codes for "how to get length of integer in java". It will help you in understanding the concepts better.

Code Example 1

int length = 0;
long temp = 1;
while (temp <= number) {
    length++;
    temp *= 10;
}
return length;

Code Example 2

int length = (int) (Math.log10(number) + 1);

Learn ReactJs, React Native from akashmittal.com