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?
Karu Raj
Ranch Hand
Joined: Aug 31, 2005
Posts: 479
posted
0
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
vipul patel
Ranch Hand
Joined: Oct 16, 2005
Posts: 146
posted
0
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
Joined: Nov 30, 2005
Posts: 54
posted
0
thank you for your suggestion! Karthik Rajashekaran
xie li
Ranch Hand
Joined: Nov 30, 2005
Posts: 54
posted
0
i know the reslut,but i cannot know how to explain.so i post it
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.