aspose file tools*
The moose likes Cattle Drive and the fly likes Something wrong with this Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "Something wrong with this" Watch "Something wrong with this" New topic
Author

Something wrong with this

Ken Whitestone
Greenhorn

Joined: Jul 22, 2013
Posts: 15
I'm having trouble with the following code:



For some strange reason, once the expression is no longer true, instead of printing a new line, then resetting the count and continuing with the remaining iterations of the loop, it continues adding 1 to the count throughout the remaining iterations of the loop, but doesn't print "args[i] ". What am I missing?
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10263
    
168

Notice that if your "if" block doesn't (intentionally or unintentionally) use a "{" to enclose the if block then only the next statement following the if statement is considered to be part of that if block. I'll just add some blank lines in your code to give you an picture on what's wrong:



See what the problem is?


[My Blog] [JavaRanch Journal]
Ken Whitestone
Greenhorn

Joined: Jul 22, 2013
Posts: 15
Yes, thank you. I knew there was something wrong because it wouldn't let me add an "else" to that "if" statement, which is what I really needed to begin with. Problem solved.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Something wrong with this