About Question com.enthuware.ets.scjp.v6.2.318 :
Posted: Mon Jun 25, 2012 1:26 am
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 );
}
}
}
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 );
}
}
}