• Post Reply Bookmark Topic Watch Topic
  • New Topic

Taking the breaks and continues out of code  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have some code that runs fine, but it has all these breaks and continues that make it ugly. Can you give me some tips to rewrite it?


(edited by Cindy to format code)
[This message has been edited by Cindy Glass (edited February 23, 2001).]
 
Bartender
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David,
It would be easier to read your loonnnnggggg example if you formatted your code to make it more readable. Please read the FAQ to learn how.
Thanks,
-Peter
 
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David,
Here is the way I did it... there are propably others too...

HTH,
-Nate
[This message has been edited by Nathan Pruett (edited February 23, 2001).]
 
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure that putting in lots of System.exit() calls is what was wanted. One of the main problems with the example given is that it is all in the main method. This just about makes sense in a program this small, but for anything larger you really should split it into smaller methods and classes. Here's another rewritten version, with things split off into (I hope) understandable concepts and operations. It's a bit more wordy, but I really do think it is more maintainable. See what you think...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!