/**
* @author lautturi.com
* Java example: java get the number of digits in a Integer
* count the digits of number in java
*/
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.*;
public class Lautturi {
public static void main(String args[]) {
int count = 0;
int num = 1234567;
while (num > 0) {
num /= 10;
count++;
}
System.out.println("the number of digits: " + count);
}
}Source:.wwwlautturi.comoutput:
the number of digits: 7