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

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

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

php - Cloud9 cloud IDE and CakePHP -