This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "break statement." Watch "break statement." New topic
Author

break statement.

Anna s Iyer
Greenhorn

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);
}
}
}
}
Thanks,
Iyer.
Shankar G
Greenhorn

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: http://aspose.com/file-tools
 
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 {}