title: How can I fill an array with all of the values between two numbers?
body: <p>I am trying to understand Arrays a bit more. I want to create a loop to fill an array with all the values between two numbers. However it seems that I can only get it to "reset" the value of a single location of the array. Everything else gets set back to zero. Below is my code:</p>
  
  <pre><code>public class ArrayTest {
  
  public static void main(String[] args) {
      // TODO Auto-generated method stub
  
      int indexLow = 3;
      int length = 10;
  
      for(int i=indexLow; i&lt;indexLow+length; i++){    
            int[] MyArray = new int[length+indexLow];
            MyArray[i] = i;
            System.out.println(MyArray[i]);
            System.out.println(Arrays.toString(MyArray));
            }
  </code></pre>
  
  <p>}
  }</p>
  
  <p>The output is not quite what I am expecting. What am I doing wrong?</p>