Skip to content

Instantly share code, notes, and snippets.

@thekalinga
Created August 28, 2019 13:03
Show Gist options
  • Save thekalinga/0bfabc816a30765555708f57212b8f88 to your computer and use it in GitHub Desktop.
Save thekalinga/0bfabc816a30765555708f57212b8f88 to your computer and use it in GitHub Desktop.
Get number of digits of a number in java8
public static int getNumOfDigits(int number) {
int numOfDigits = 0;
int remainder = number;
do {
numOfDigits++;
remainder = remainder / 10;
} while (remainder > 0);
return numOfDigits;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment