title: Empty integer array in java
body: <blockquote>
  <p>Write a function that takes an array as input and returns an array of 2 numbers. The returned array contains the sum of even numbers and sum of odd numbers from the input.</p>
  <p>If any of the input is null it should be treated as an empty array</p>
  <p>Example:
  Input:<br />
  [30, 18, 2, 83, 20, 71]<br />
  Output:<br />
  [70, 154]</p>
  <p>Input:<br />
  [14, 11, 10, 67, 41]<br />
  Output:<br />
  [24, 119]</p>
  <p>Input:
  [36, 24, -82, 29, 44, -3, -100, -5, 49]
  Output:
  [-78, 70]</p>
  </blockquote>
  <p>The function that I have written is</p>
  <pre><code>public int[] getSumOfEvensAndOdds(int[] input) {
          
          int x[] = input;
          int even = 0, odd = 0;
          for (int i = 0; i &lt; x.length; i++) {
              if (x[i] % 2 == 0)
                  even += x[i];
              else
                  odd += x[i];
          }
          int[] ans={even, odd};
          return ans;
      }
  </code></pre>
  <p>But how should I incorporate the part of the empty array?</p>