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 labels - great question from appliedreasoning mock --plz help 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 "labels - great question from appliedreasoning mock --plz help" Watch "labels - great question from appliedreasoning mock --plz help" New topic
Author

labels - great question from appliedreasoning mock --plz help

sarim raza
Ranch Hand

Joined: Nov 02, 2000
Posts: 232
public class LabelTest {
public static void main(String args[]) {
int j =3;
int y=0;
mainLabel: for (int i =0;i<j;i++) {<br /> if (i>1) continue mainLabel;
y++;
}
mainLabel: for (int i =0; i<y; i++) {>
y--;
}
System.out.println(y);
}

//THE OUTPUT IS 1, HOW ??
I AM CONFUSED ABOUT THE USE OF CONTINUE, WHICH MAINLABEL IS IT CALLING, EXPLAIN THE MECHANISM ?
sunilkumar ssuparasmul
Ranch Hand

Joined: Dec 13, 2000
Posts: 142
please pen down u r question properly .
------------------
"Winners don't do different things
They do things differently"


"Winners don't do different things<br /> They do things differently"
Sivaram Ghorakavi
Ranch Hand

Joined: Nov 30, 2000
Posts: 56
From my understanding lables are associated to the immediate loops. So in this case the first mainLabel: is associated to the first for(; loop and the second mainLabel: is associated to the second.
Hope this helps...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: labels - great question from appliedreasoning mock --plz help