The trouble is with the while(false)
continuation condition. Being a do while(false)
statement, this means that it can never loop more than once. That is, when you try to jump the execution to the labeled statement, it won't cycle again through the do while
because the continuation condition (false
) is not validated, even if you think that continue
will make the execution loop again.
So it will never increment numb
more than once per next()
method execution.
I'd do something like the following:
nextCandidate:
do{
numb += 2;
int numbSqrt = (int)java.lang.Math.sqrt(numb);
for (int i = 3; i <= numbSqrt; i = i+2)
{
if (numb % i == 0)
{
continue nextCandidate;
}
}
break;
}while(true);