title: generic list add method
body: <p>I tried to make method which  inserts element at the specified position in this list.
  Then Shifts the element &amp; subsequent elements currently at that position to the
  Right by adding one to their indices, i know there is shortcut for this method but I am suppose to do it, here what i tried to do but it's not working.</p>
  <pre><code>private T a[];
  private int count;
  private  int size = 0; 
  
  public int size() { return size; }
  
  public   void add(int index,T t) throws Exception {
  
      if (index &lt; 0 || index &gt; = a.length){   
          throw new IndexOutOfBoundsException();  
      }
  
      Object[] temp = new Object[a.length + 1];  
  
      for (int k = 0, j = 0; j &lt; temp.length; ++ k, ++ j){  
          if ( k == index ) {  
              temp[index] = t;  
              --k; 
          } else {
              temp[j] = a[index]; // 
          }
      }
      a = (T[]) temp;
  }
  </code></pre>