title: Find smallest product of 3 numbers in the array [error in code?]
body: <p>I am trying to make a code to do just that, but I do not complete all test cases on the website I put it on. Since I do not know what the tests are I tried to run some on my own, but I am unable to find the problem. </p>
  
  <p>Now, I understand that my code can be simplified, but I made it bigger for clarity. I am a noob, don't hate.</p>
  
  <p>Examples: </p>
  
  <p>For arr = [1, 2, 3], the output should be smallestProduct(arr) = 6</p>
  
  <p>The only option is 1 * 2 * 3 = 6.</p>
  
  <p>For arr = [-1, 0, -2, 3], the output should be smallestProduct(arr) = 0
  There are four possible products, and the smallest one is 0:</p>
  
  <p>EDIT: I solve the challenge with:
  EDIT2: Yeah, I missed 0. Damn it.</p>
  
  <pre><code>Arays.sort(arr);
   return Math.min(arr[0] * arr[1] * arr[2], arr[0] * arr[arr.length-1] * arr[arr.length-2] );
  </code></pre>
  
  <p>But I would like to know what was wrong with ifs and elses</p>
  
  <pre><code>public static int smallestProduct(int[] arr) {
  
          Arrays.sort(arr);
       //all positive
      if (arr[0] &gt; 0) {
          return  arr[0] * arr[1] * arr[2];
      }
  
      //all negative
      else if (arr[arr.length-1] &lt; 0){
  
          return arr[0] * arr[1] * arr[2];
      }
  
      //one is negative
      else if (arr[0] &lt; 0 &amp;&amp; arr[1] &gt; 0) {
  
          return  arr[0] * arr[arr.length-1] * arr[arr.length-2];
      }
  
      //two negative
      else if (arr[0] &lt; 0 &amp;&amp; arr[1] &lt; 0 &amp;&amp; arr[2] &gt; 0) {
          return arr[0] * arr[arr.length-1] * arr[arr.length-2];
      }
  
      //more than two negative
      else {
  
          return arr[0] * arr[1] * arr[2];
      }
  </code></pre>