I have this piece of code and i dont understand why I m getting the following error:
local variables referenced from a lambda expression must be final or effectively final
Here is my code
public int firstMissingPositive(int[] nums) {
int k;
for (int i = 1;; i++) {
if (!Arrays.stream(nums).anyMatch(x -> x != i)) {
k = i;
break;
}
}
return k;
}