I have a while loop that isn’t executing. I don’t believe there is an infinite loop or priming problem, but is there? I can’t find my logical error!
public class Test
{
public static void main (String [] args)
{
int i = 1;
int j = 1;
while ((i < 10) && (j*j != 25));
{
i++;
++j;
System.out.println( i * j );
}
}
}
Remove the semicolon after the while loop
Any statement that directly comes after the loop declaration is considered the whole block if it’s not enclosed with braces.
I.E
Is treated as
A single semicolon is considered as empty statement and thus made up your whole loop body.