title: Moving all non-zero integers to the beginning of an array
body: <p>I am trying to move all non-zero integers to the beginning/left-side of the array 'a.'(for example {0,0,4,3,0} becomes {4,3,0,0,0}) </p>
  
  <p>This is my program. It compiles and runs with no errors but the array ends up with only zeros. Any suggestions would be appreciated.</p>
  
  <pre><code>int[] squeezeLeft(int[] a) {
      int count = 0;
      //creates new array
      int [] a2 = new int[a.length];
      //loops through a
      for (int i = 0; i&lt; a.length; i++){
          //gets a temporary value from a[i]
          int temp = a[i];
          //assigns a[i] to temporary variable
          a[count] = temp;
          a[i] = 0;
                    /* raises count integer by one, so the following indice which is zero, is replaced
  
                    by  the following non=zero integer*/
          count++;
      }
      return a2;
  }
  </code></pre>