title: Get an array, decide if the number is closer to right/left zero
body: <p>I'm trying to write a code which gets an integer array, check every index's value, if the index's value is zero it goes on until it finds an index with value which isn't zero and then changes its value depending on the closer zero in the array. for example:</p>
  
  <pre><code>  BEFORE  ( 0, 1 , 1 , 1 , 1 , 0 , 1 , 1 , 1 , 1 , 1 , 0) 
  
    AFTER ( 0, 1 , 2 , 2 , 1 , 0 , 1 , 2 , 3 , 2 , 1 , 0) 
  </code></pre>
  
  <p>This is my code:</p>
  
  <pre><code>       public static void zeroDistance (int [] a)
     {
         int counterToZero = 0;
         int counterToZeroII = 0;
         for ( int i = 0; i &lt; a.length; i++ ){
                  counterToZero = 0;
                  counterToZeroII = -1;
                  if ( a[i] != 0 ){
                    for ( int j = i; a[j] != 0; j++)
                    { // From i to the next zero
                            counterToZero++;
                    }
                    for ( int h = i; a[h] != 0 ; h--) // From i to first zero (goes beckwards)
                    {
                          counterToZeroII++;
                    }
                    if ( counterToZero &gt; counterToZeroII ) 
                    a[i] = counterToZero;
                    else if (counterToZero &lt; counterToZeroII)
                    a[i] = counterToZeroII;
                    else if ( counterToZero == counterToZeroII)
                    a[i] = counterToZero;
                  }
         }
         int[] b = a;
         for (int h = 0; h &lt; b.length; h++)
          System.out.println(b[h] + "/n");
     }
  </code></pre>
  
  <p>This is the output I'm getting, and I'm kinda lost of where the problem is, I'm still looking on the code and trying to detect what I did wrong, if you can help me out and point where I may be wrong it'd be very helpful. also, if u know another way of "sort checking" like using recursion it'd be much appreciated, I'm trying to get used to using recursion but it's still hard for me to implement that thus I'm using for loops at the moment.</p>
  
  <p>0/n
  2/n
  1/n
  0/n
  5/n
  4/n
  3/n
  3/n
  4/n
  0/n</p>