Empty array returns true? Given an array of ints, return true if every element is a 1 or a 4
<blockquote>
<pre><code>Given an array of ints, return true if every element is a 1 or a 4.

only14([1, 4, 1, 4]) → true
only14([1, 4, 2, 4]) → false
only14([1, 1]) → true
</code></pre>
</blockquote>

<p>I came up with the following algorithm which returns all the expected answers, EXCEPT for an empty array which should return <code>true</code>:</p>

<pre><code>public boolean only14(int[] nums) {

  boolean flag = false;

  for (int i = 0; i &lt; nums.length; i++) {

    if (nums[i] == 1 || nums[i] == 4) {
      flag = true;
    } else {
      return false;
    }
  }
  return flag;
}
</code></pre>

<p>From the solutions, the following input should yield <code>true</code>, but I can't figure out why:</p>

<p><code>only14([]) → true</code></p>

<p>I understand the default value is 0, so what am I missing such that I should expect the return value of the boolean to be <code>true</code>?</p>