title: How to I add in the middle of an array?
body: <p>I am trying to make a method called insertAt that takes 3 parameters (int index, int n, int value) so that if I call: 
  list.insertAt(2, 4, 98) on an array of [12, 42, 8, 934], it should now store [12, 42, 98, 98, 98, 98, 8, 934].</p>
  
  <p>int index is where I start to put the values</p>
  
  <p>int n is how many values</p>
  
  <p>int value is the actual value or number I want to put in.</p>
  
  <p>I am making this method in a class called ArrayIntList:</p>
  
  <pre><code>public class ArrayIntList {
      private int[] elementData; // list of integers
      private int size;          // current # of elements in the list 
  }
  </code></pre>
  
  <p>I tried making the method below but I am still stuck on what I am missing. If you guys can help me out I would appreciate it a lot!</p>
  
  <pre><code>public void insertAt(int index, int n, int value) {
      if (index &lt; 0 || index &gt; size || n &lt; 0) {
          throw new IllegalArgumentException();
      }
      size = size + n;
      for (int i = 0; i &lt; n; i++) {
          elementData[(size - 1) - i] = elementData[(size - n) + i];
          elementData[n + i] = value;
      }
  }
  </code></pre>