title: How to insert random numbers into an array and sort them
body: <p>My code is supposed to take the random number generated in the random method and sort them but it's only giving me one number.</p>
  
  <p>My program is a random number generator that is supposed to make 1000 numbers that I can sort but my code only inserts one number into the array.</p>
  
  <pre><code>public static void main(String[] args) {
      // write
  
      int max = 1000;
      int min=0;
      int range = max - min + 1;
  
      // generate random numbers within 1 to 10
      for (int i = 0; i &lt; 1000; i++) {
          int rand = (int) (Math.random () * range) + min;
          System.out.println ( rand );
  
  
  
  
          int array[] = {rand};
          int size = array.length;
  
          for ( i = 0; i &lt; size - 1; i++) {
              int min1 = i;
  
              for (int j = i + 1; j &lt; size; j++) {
                  if (array[j] &lt; array[min1]) {
                      min = j;
                  }
              }
              int temp = array[min1];
              array[min1] = array[i];
              array[i] = temp;
          }
  
          for (int k = 0; k &lt; size; i++) {
              System.out.print(" " + array[i]);
          }
      }
  }
  </code></pre>