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 );
}
}
}
About Question com.enthuware.ets.scjp.v6.2.318 :
Moderators: Site Manager, fjwalraven
-
- Site Admin
- Posts: 10066
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.318 :
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!
"...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.
Who is online
Users browsing this forum: Bing [Bot] and 76 guests