Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

how to find numbers of digits in java

  public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int num = input.nextInt();

        int count = 0;

        while (num > 0) {
            num /= 10;
            count++;
        }
        System.out.println("number of digits: " + count);
    }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #find #numbers #digits #java
ADD COMMENT
Topic
Name
9+1 =