File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Something wrong with this

Ken Whitestone

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

Joined: Jul 20, 2005
Posts: 10441

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

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.
I agree. Here's the link:
subject: Something wrong with this
It's not a secret anymore!