title: How to generate random numbers with r.nextInt() except one number?
body: <p>I've come to a part in my code where I must generate a random number every time I press a button (r in this case). When I press this button, I want it to generate a number between 0 and n (3 in this case), but I don't want it to generate a number it previously generated. So I do not want the same number to be generated twice in a row. So 2 then 2 is bad. 2 then 0 then 2 is OK however.</p>
  
  <p>I've looked around on here for questions similar to mine but none of them have really helped. Everyone else is generating once with the exception of numbers in an array or something. I'm constantly generating and I want to be able to detect the same number previous.</p>
  
  <p>I am using the Random class, I have considered using the math.random class but that is between 0 and 1 so that isn't really too useful. Any help would be greatly appreciated, thanks! :D</p>