This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA 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
 
jQuery in Action, 2nd edition
 
subject: if inside for method wont work?!? why?