What's Wrong With This Code

I just started learning Java with Oreilly’s Head First Java, and it’s frustrating writing my first code using notepad and not getting it right.

Please help point out what is wrong with this code:

public class Loopy {
public static void main (String args) {
int x = 1;
System.out.println(“Before the Loop”);
While (x < 4); {
System.out.println(“In the loop”);
System.out.println("Value of x is " + x);
x = x + 1;
}
System.out.println(“This is after the loop”);
}
}

Thanks

While (x < 4); {

it should be while not While and you shouldn’t have a ; after while loop



Note: java and javascript are not same

It worked. Thanks so much.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.