wood burning stoves 2.0
The moose likes Beginning Java and the fly likes Better way than this one? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Better way than this one?" Watch "Better way than this one?" New topic

Better way than this one?

JJosshh xpto

Joined: Oct 27, 2005
Posts: 1
Hello everyone.

Simple question.
Someone insert a numer like e.g 123
the output is 3 (number of digits)
Is there any easy way to do that instead of this :

System.out.print ( "insert number: ");
int number = Integer.parseInt(br.readLine().trim());

int count = 0;
while(number >0){
int digit= number%10;
number /=10;
if(number >= 0) count++;

I know there's a better way to do this , like with a for- loop or something.
I'm getting a "blank" , can't remember .

Thanks a lot.

Joanne Neal

Joined: Aug 05, 2005
Posts: 3742

I agree. Here's the link: http://aspose.com/file-tools
subject: Better way than this one?
jQuery in Action, 3rd edition