title: How to exclude number in random number in Java
body: <p>So I will get a random number between 1 to 9999, but I want to exclude 1111, 3333, 4444, 7777 and is that use while loop?</p>
  
  <pre><code>Random r = new Random();
  
  int x = r.nextInt(9999);
  
  while (x == 1111 || x==3333){
      x = r.nextInt(9999) + 1;
  } 
  </code></pre>