title: Creating 20 different numbers from 1-30 no duplicates
body: <pre><code>public class randomNumbers {
  public static void main(String args[]){
      int[] nums = new int[20];
      Random rn = new Random();
      int temp;
  
      for(int i=0;i!=20;i++) {
          temp=rn.nextInt(30)+1;
          for(int j=0; j&lt;i; j++) {
              if(temp==nums[j]) {
                  j=0;
                  temp = rn.nextInt(30)+1;
              }
  
          }
          temp = nums[i];
      }
  
      for(int i=0; i!=20; i++) {
          System.out.println(nums[i]);
      }
  }
  </code></pre>
  
  <p>Here is my code for the program. But the output is all zeros. The first loop should run 20 times and generate a random int from 1-30, then the nested loop should test and see if it is in the array.If true then a new temp should be created and j set to 0 to check again. If not, then the nested loop should finish and temp set equal to nums[i]. But like i said my output is all zeros.</p>