Check out example codes for "count the number of digits in an integer in java". It will help you in understanding the concepts better.

Code Example 1

// JAVA Code to count number of 
// digits in an integer 
import java.util.*; 
  
class GFG { 
  
    static int countDigit(long n) 
    { 
        return (int)Math.floor(Math.log10(n) + 1); 
    } 
  
    /* Driver program to test above function */
    public static void main(String[] args) 
    { 
        long n = 345289467; 
        System.out.print("Number of digits : " + countDigit(n)); 
    } 
} 
// This code is contributed by Arnav Kr. Mandal.

Code Example 2

import java.util.Scanner;
public class CountingDigitsInInteger {
   public static void main(String args[]){
      Scanner sc = new Scanner(System.in);
      int count = 0;
      System.out.println("Enter a number ::");
      int num = sc.nextInt();
      while(num!=0){
         num = num/10;
         count++;
      }
      System.out.println("Number of digits in the entered integer are :: "+count);
   }
}

Learn ReactJs, React Native from akashmittal.com