File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Do/While and If/Else statement help/confusion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Do/While and If/Else statement help/confusion" Watch "Do/While and If/Else statement help/confusion" New topic

Do/While and If/Else statement help/confusion

Reno Madrigal

Joined: Sep 24, 2007
Posts: 18
Hello again, I am having quite a bit of confusion with these statements; here is what my program statment looks like.

I really think I have possibly overused the "{}". But my main problem is configuring the do/while loops and the if/else statments inside them, to me its confusing. Thanks a ton for any pointers or direction.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33124

I've added some indentation to show which braces go with what. It's not that you have too many. It's that they aren't in the correct places in terms of matching up.

While technically the if/else doesn't require braces (because they only contain one statement), it is still good practice to have them there. If someone adds a statement in the future, they will thank you!

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: Do/While and If/Else statement help/confusion
It's not a secret anymore!