title: Add odd numbers between a closed range to an array
body: <p>I am doing code challenge where given two integers <code>l</code> and <code>r</code>, I have to print all the odd numbers between <code>i</code> and <code>r</code> (<code>i</code> and <code>r</code> inclusive). The function must return an array of integers denoting the odd numbers between <code>l</code> and <code>r</code>.</p>
  
  <p>This is what I have so far</p>
  
  <pre><code>static int[] oddNumbers(int l, int r) {
      int[] theArray = new int[r];
      for (int i = l; i &lt; theArray.length; i++) {
          if (i % 2 != 0) {
              for (int n = 0; n &lt; theArray.length; n++) {
                  theArray[n] = i;
              }
          }
      }
      return theArray;
  
  }
  </code></pre>
  
  <p>So at the moment this code if you give it values 2 and 5 should return 3,5. However, this only returns 33333. What am I doing wrong? And how can I improve this code?</p>