title: Generate only positive random numbers and sort them
body: <p>I am trying to generate positive numbers and sort them ascending order, without using <code>arrays.sort</code>. </p>
  
  <p>This code, asks for how many random numbers and then sort them and print it out. My code asks for how many and is printing out one less than the given. </p>
  
  <p>For example  when i ask for 2, it prints out only one. Unable to find the mistake or error. </p>
  
  <p><strong>Code</strong></p>
  
  <pre><code>import java.util.*;
  
  public class Sort {
  
      public static void main(String args[]) {
          Scanner in = new Scanner(System.in);
          System.out.print("How many numbers do you want? ");
          int howMany = in.nextInt();
          int[] myArray = getRandomArray(howMany);
  
      }
  
      /* public static int bsearch(int[] arr, int key)
              {
  
              }*/
      public static int[] getRandomArray(int howMany) {
          int[] returnMe = new int[howMany]; // Assume size &gt;= 0
          Random rand = new Random();
          for (int i = 0; i &lt; howMany; i++) {
              returnMe[i] = rand.nextInt(Integer.MAX_VALUE) + 1;
              System.out.print(returnMe[i] + " ");
              for (i = 1; i &lt;= returnMe.length; i++) {
                  for (int j = i + 1; j &lt; returnMe.length; j++) {
                      int tmp = 0;
                      if (returnMe[i] &gt; returnMe[j]) {
                          tmp = returnMe[i];
                          returnMe[i] = returnMe[j];
                          returnMe[j] = tmp;
                      }
                  }
              }
          }
          return returnMe;
      }
  }
  </code></pre>