```
public int findMaxConsecutiveOnes(int[] nums) {
if (nums == null || nums.length == 0) return 0;
int countAll = 0;
int countWithoutFlip = 0;
boolean flipped = false;
int max = 0;
for (int num : nums) {
if (num == 0) {
max = Math.max(countAll, max);
if (flipped) {
countAll = countWithoutFlip + 1;
countWithoutFlip = 0;
} else {
countAll++;
countWithoutFlip = 0;
flipped = true;
}
} else {
countAll++;
countWithoutFlip++;
}
}
max = Math.max(countAll, max);
return max;
}
}
```