File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 REST with Spring (video course) this week in the Spring 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.
jQuery in Action, 3rd edition