Jak uzyskać długość liczby całkowitej w Javie
int length = (int) (Math.log10(number) + 1);
Frightened Frog
int length = (int) (Math.log10(number) + 1);
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int length = String.valueOf(n).length();
System.out.print(length);
int n = 1000;
int length = (int)(Math.log10(n)+1);
//NB: only valid for n > 0