This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes break statement. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "break statement." Watch "break statement." New topic

break statement.

Anna s Iyer

Joined: Aug 21, 2000
Posts: 24
Why did break statement not going to the Inner loop by specifying the label Inner in the following code?.
class forloop {
public static void main (String args[]) {
//int j,k;
Outer: for(int i=0; i < 2; i++) {
System.out.println("i out "+i);
Inner:for(int j=0; j < 3; j++) {
if (i==j) {
break Inner; //Does not go to the Inner label and increments j
System.out.println("i is " +i +" j is " +j);
Shankar G

Joined: Sep 24, 2000
Posts: 16
Break statement would try to break out of the enclosing loop while continue statement would try to continue the enclosing loop with the next loop-variable value -- if your intention is to continue the loop, use continue <label> instead.
Hope this helps.
- Shankar.
I agree. Here's the link:
subject: break statement.
Similar Threads
switch and labeled break
Doubts about break
Trying to understand labeled "break" with for loops
why does 'break' traverse one more time
Break with if {}