About Question com.enthuware.ets.scjp.v6.2.318 :

All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.

Moderators: Site Manager, fjwalraven

Post Reply
ETS User

About Question com.enthuware.ets.scjp.v6.2.318 :

Post by ETS User »

Using a continue in a while loop causes the loop to break the current iteration and start the next iteration of the loop assuming that the while condition still holds true is possibly wrong. The while condition is always checked before entering in the while loop.

class TestClass
{
public static void main(String[] args)
{
Boolean flag = true;
while(flag){
System.out.println("A -> "+ flag );
flag = false;
System.out.println("B -> "+ flag );
if(flag==false)
continue;

System.out.println("C -> "+ flag );

}
}
}

admin
Site Admin
Posts: 10066
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question com.enthuware.ets.scjp.v6.2.318 :

Post by admin »

You are right but it seems what the statement wants to convey is something like this:
"...start the next iteration of the loop. (Assuming that the while condition still holds true.)." It does not intend to mean that the while condition is assumed to be true always when a continue is encountered. It intends to mean that the next iteration is executed if the condition is true.

It is indeed badly worded and will be fixed asap.

thank you for your feedback!
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 76 guests