public int[] frontPiece(int[] nums) { if (nums.length <= 2) { return nums; } else { int[] a = new int[2]; a[0] = nums[0]; a[1] = nums[1]; return a; } } public int[] frontPiece(int[] nums) { if (nums.length < 2) { return nums; } else { int[] a = { nums[0], nums[1] }; return a; } } // Notice that if nums.length == 2, // it doesn't matter which branch of the if statement processes the array. // Both branches will do it correctly!