title: How to double the size of an array
body: <p>I have to implement an array that takes its elements from a random generator. Whenever the array reaches it's last element a method resize() will be called to increase the size of the array. In my code every thing goes alight until invoking resize() method, it does not do any effect on the size of the array. It supposed to increase the size of the array to allow more elements to be entered.</p>
  
  <pre><code>    for (int j=0; j&lt;arr.length-1; j++) {
          random= generator.nextInt(arr.length*4) ;
          arr[j]=random;
  
          }
  
      if(arr_size==arr.length){
          resize(arr);
          for (int h=0; h&lt;(arr.length-1)*2; h++) {
              random= generator.nextInt(arr.length*4) ;
              arr[h]=random;}
      }
  </code></pre>
  
  <p>Here is resize():</p>
  
  <pre><code>     private static void  resize(int[] arr) {
  
      int[] tmp = new int[2*arr.length];
      System.arraycopy(arr,0,tmp,0,arr.length); 
      arr = tmp;
  }
  </code></pre>