my dog learned polymorphism*
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
Author

Do/While and If/Else statement help/confusion

Reno Madrigal
Greenhorn

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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30537
    
150

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!



[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Do/While and If/Else statement help/confusion