File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes length....seems simple...but it isnt working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "length....seems simple...but it isnt working" Watch "length....seems simple...but it isnt working" New topic

length....seems simple...but it isnt working

amr amr

Joined: Mar 27, 2004
Posts: 6
I have a string that can be like

I want to count the number of ones in the string...which should be 6 according to this example...but the length() functino doesnt seem to be returning the right value...helpp!!
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
What value seems to be returned by b.length()? How is it that you are using/displaying this value?
When I run your code, with a System.out.println(len); immediately after it, I get 6, as expected.
[ April 09, 2004: Message edited by: Dirk Schreckmann ]

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
I agree. Here's the link:
subject: length....seems simple...but it isnt working