JAVA输入整形数字,判断是几位数

import java.util.Scanner;

public class numberLength {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个整数:");
        int num = sc.nextInt();        
        System.out.println("你输入的是一个:"+testNumber(num)+"位数");
    }
    public  static  int testNumber(int  a) {
        String str = a+"";
        int l= str.length();
        return l;
    }
}