shortcut method for finding number of digit in java

import java.util.Scanner;
import java.lang.Math;
public class Length {
    public static void main(String[] args) {
        System.out.print("\nEnter number: ");
        Scanner scanner = new Scanner(System.in);
        double num = scanner.nextDouble();
        int result = ((int) Math.log10(num))+1;
        System.out.println("Result: "+result);
    }
}

_____________________________________________________________
                                    

Comments