public int findMaxConsecutiveOnes(int[] nums) {

```
int max = 0;
int sum = 0;
for(int i = 0; i < nums.length; i++) {
if(nums[i] == 0) {
if(sum > max)
max = sum;
sum = 0;
} else
sum ++;
}
// take care from last consecutive ones
if(sum > 0 && sum > max)
max = sum;
return max;
}
```