This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
amr amr
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 7023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic