wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes if inside for method wont work?!? why? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "if inside for method wont work?!? why?" Watch "if inside for method wont work?!? why?" New topic
Author

if inside for method wont work?!? why?

Dmitri Makovetskiy
Ranch Hand

Joined: Jun 21, 2010
Posts: 128






my goal is to find how many times a character repeatself in the sentence.. but it fails to trigger the if method correctly. why.?
Tom Reilly
Rancher

Joined: Jun 01, 2010
Posts: 618
You if statement is working fine. In your loop you are assigning number2 to number + 1 but number is always zero so number2 is always set to 1. I think you meant
Dmitri Makovetskiy
Ranch Hand

Joined: Jun 21, 2010
Posts: 128
Tom Reilly wrote:You if statement is working fine. Every time through your loop you are assigning number2 to number + 1 but number is always zero so number2 is always set to 1. I think you meant



Tom . thank you. you found my mistake, i wasnt very smart was i...xD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: if inside for method wont work?!? why?
 
Similar Threads
why does this code work
why does it tell me that there is else without if (java programming)?
3 lines i dont understand
A code i cant make work
i am struggling with a variable to complete teh code