Is there a way to break out of a while loop before the original condition is made false?

Posted by David on Stack Overflow See other posts from Stack Overflow or by David
Published on 2010-04-15T22:40:18Z Indexed on 2010/04/15 22:43 UTC
Read the original article Hit count: 190

Filed under:
|

Is there a way to break out of a while loop before the original condition is made false?

for example if i have:

while (a==true) 
{ 
    doSomething() ; 
    if (d==false) get out of loop ;
    doSomething_that_i_don't_want_done_if_d_is_false_but_do_if_a_and_d_are_true() ;
} 

Is there any way of doing this?

© Stack Overflow or respective owner

Related posts about java

Related posts about while-loops