How to find length of long integer value using String class

This is the first solution to find the length of a given long integer value. This approach converts long integer to string and uses the length method.

import java.util.Scanner;

public class LengthOfLongInteger {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		@SuppressWarnings("resource")
		Scanner inpLongInt= new Scanner(System.in);
		
		//Input a long integer
		System.out.println("Enter long Integer=");
		long longNum=inpLongInt.nextLong();
		System.out.println("The long integer is="+longNum);
		
		// Convert long number into a String and use the length function		
        String longInt2Str=String.valueOf(longNum);
		System.out.println("The Length of the long integer "+longNum+" is="+longInt2Str.length());	
	}
}
Output:
 Enter long Integer=
 1234567891234567891
 The long integer is=1234567891234567891
 The Length of the given long integer 1234567891234567891 is=19