• Post Reply Bookmark Topic Watch Topic
  • New Topic

Code running in a loop sometimes  RSS feed

 
Tiberius Marius
Ranch Hand
Posts: 115
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand why this code sometimes runs in a loop . The code is meant to select randomly a number between 1 and 53 without being one of the numbers from a variable number of parameters .I m having a hard time understanding why it runs in a loop sometimes (i added print statements to see what gets executed but when in a loop nothing seems to get executed of the method)

 
fred rosenberger
lowercase baba
Bartender
Posts: 12564
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
More System.out.println statements would help.

What happens if you get a value like 4 the first time you get n? What happens to "decider"?

Then, when we loop back in the do-loop, what will be the value of decider? Can it ever change?
 
Tiberius Marius
Ranch Hand
Posts: 115
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understand the error , i only have do set decider to true first thing inside the do block to prevent the loop.Thanks!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!