File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes for loops Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "for loops" Watch "for loops" New topic
Author

for loops

teja nelluri
Greenhorn

Joined: Jun 22, 2000
Posts: 8

hi everybody,
i am very confusing about this for loops.
please tell me the output of this.if possibel
please exaplian about what is continue outer,
break,continue.
thanks.
outer: for (int i = 0; i < 2; i++) {
for (int j = 0; j < 3; j++) {
if (i == j) {
continue outer;
}
System.out.println("i = " + i + " j = " + j);
}
}
Aru
Ranch Hand

Joined: Jul 20, 2000
Posts: 112
Hi Teja,

Lemme try to explain this...
outer: for (int i = 0; i < 2; i++) {
for (int j = 0; j < 3; j++) {
if (i == j) {
continue outer;
}
System.out.println("i = " + i + " j = " + j);
}
}
In this code, When the compiler encounters "continue outer" for the first time, would be when 1= 0 & j = 0. Then instead of continuing the the second loop the control jumps to the first loop to continue processing ... & so on
Thx
Aruna
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: for loops