Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

labels - great question from appliedreasoning mock --plz help

 
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please pen down u r question properly .
------------------
"Winners don't do different things
They do things differently"
 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Who knew that furniture could be so violent? Put this tiny ad out there to see what happens:
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!