title: Finding closest number to 0
body: <p>I have an array of integers, and I need to find the one that's closest to zero (positive integers take priority over negative ones.)</p>
  <p>Here is the code I have so far:</p>
  <pre><code>public class CloseToZero {    
      public static void main(String[] args) {    
          int[] data = {2,3,-2};    
          int curr = 0;    
          int near = data[0];     
          // find the element nearest to zero    
          for ( int i=0; i &lt; data.length; i++ ){    
              curr = data[i] * data[i];     
              if ( curr &lt;= (near * near) )  {     
                  near = data[i]; 
              }     
          }    
          System.out.println( near );    
      }    
  }
  </code></pre>
  <p>Currently I'm getting a result of -2 but I should be getting 2. What am I doing wrong?</p>