Is there a neater way for getting the number of digits in an int than this method?
int numDigits = String.valueOf(1000).length();
You could could the digits using successive division by ten:
int a=0; if (no < 0) { no = -no; } else if (no == 0) { no = 1; } while (no > 0) { no = no / 10; a++; } System.out.println("Number of digits in given number is: "+a);