arrays - Java Method while-looping endlessly even though breakout case seems to be met -
i have while loop loop condition boolean variabke true. loop has logic in set boolean variable false when it's time exit loop. however, never exits. have confirmed printing message variable being set false.
here précis of method:
public void collapse(){ boolean status=true; while(status=true){ // processing if (some condition) { system.out.println("setting status false"); status = false; } // more processing doesn't set status true } } what's going on here?
you're assigning status true in while statement, instead of checking equality. either change status == true, or use status.
Comments
Post a Comment