• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

continue

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
public class Cjgreen{
public static void main(String argv[]){
Cjgreen c = new Cjgreen();
c.jgreen();

}
public void jgreen(){
int iNum =1 ;
while(iNum >0){

toffer:
for(int i = 0; i < 3; i ++){
continue toffer;
System.out.println(i);
}
}

iNum --;
}
what is the reslut?
 
Ranch Hand
Posts: 481
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Xie

I dont understand why do you post the questions without even trying by yourself.

Have you ever compile this question.

Try and see then only you will learn lot

not just by posting questions and expecting ranchers to post answer.

,...............

THe answer to the above code is

Compile time error ....If you want to know exactly why do compile yourself and check out

all the best
 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have copied code snippet as follow.

for(int i = 0; i < 3; i ++){
continue toffer;
System.out.println(i);
}

Now look at the structure of code very carefully. Here

continue toffer;

is not surrounded by the if condition. so System.out.println(i) will not be executed at all. It means that compiler will produce an 'compile time error' that code is not reachable.
 
xie li
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you for your suggestion!
Karthik Rajashekaran
 
xie li
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i know the reslut,but i cannot know how to explain.so
i post it
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic