I have 2 questions concerning them.
1. What kinds of things can they break out of? Is it only for and while statements?
2. If I have a nested loop, do I have to use 2 break statements (one for each loop) to get out of both?
Printable View
I have 2 questions concerning them.
1. What kinds of things can they break out of? Is it only for and while statements?
2. If I have a nested loop, do I have to use 2 break statements (one for each loop) to get out of both?
Hi guys hows it goin, this is my first ime here
troysmith, the place for that kind of post is the "introductions" forum
As per usual, the tutorials are the first place to go. Look at this: Branching Statements (The Java™ Tutorials > Learning the Java Language > Language Basics)
There you'll find this quote and more:As always, the best way to test this is to run this for yourself.Quote:
An unlabeled break statement terminates the innermost switch, for, while, or do-while statement, but a labeled break terminates an outer statement.
Good luck.