title: Expanding an Array?
body: <p>I know you can't dynamically expand a normal array but is this a valid way of doing it?</p>
  
  <pre><code>public int size = 0;    
  public String[] OrigArray = new String[size+1]; 
  
  public void expand(){
  
  
              String[] tempArray = new String[size+1];    
  
              tempArray = (String[])OrigArray.clone();
  
              OrigArray = new String[size+1];
  
              OrigArray = (String[])tempArray.clone();    
  
              size++;         
  
      }
  </code></pre>
  
  <p>I'm aware of much better methods than trying to use a normal array but I'd like to figure this for just using a normal array first. </p>
  
  <p>My desire is that it starts off with <code>OrigArray</code> being 0+1 (so 1) and when <code>expand()</code> is called the new <code>tempArray</code> is made that is the same size as the <code>OrigArray</code> and this then holds <code>OrigArray</code> while <code>OrigArray</code> is declared again with <code>size+1</code> then the <code>tempArray</code> is copied back to the newly sized <code>OrigArray</code>. This makes sense to me, but I keep getting out of bound exception? </p>