Java loop is not terminating -


can tell me why loop continuous?

while(sum !=7 || sum!=pt){         system.out.println(sum);         die1.roll();         die2.roll();         sum = (die1.getnumber() + die2.getnumber());         joptionpane.showmessagedialog(null, "the sum of numbers "+sum); } 

even if sum equal 7 or variable pt loop keep on going reason.

change || &&. loop continue while 1 of conditions evaluates true. in order make stop when 1 becomes true, need change boolean operator.


Comments

Popular posts from this blog

angularjs - Showing an empty as first option in select tag -

qt - Change color of QGraphicsView rubber band -

c++ - Visible files in the "Projects" View of the Qt Creator IDE if using the CMake build system -