wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Java Code Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java Code Error" Watch "Java Code Error" New topic

Java Code Error

Trae Carrington

Joined: Feb 01, 2008
Posts: 2
Just now getting into java with Head First Java trying to run the following code and get the error

DooBee.java:9: ';' expected
If(x==3) {

What is wrong?

public class DooBee {
public static void main (String[] args){
int x = 1;
while(x<3) {
If(x==3) {
Joe Ess

Joined: Oct 29, 2001
Posts: 8836

Welcome to the JavaRanch.
Java is case-sensitive. The word "if" is different from the word "If". "if" is used for flow control. "If" is undefined, and since it is followed by parenthesis, the compiler assumes you are referencing a method named "If" and complains because you haven't terminated the method call with a ";".

"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Trae Carrington

Joined: Feb 01, 2008
Posts: 2
Thanks for the help. Still new at it rather than just move on I always try to find out what causes an error so don't pick up a bad habit.
I agree. Here's the link: http://aspose.com/file-tools
subject: Java Code Error
Similar Threads
Another Question from the book "Head First Java"
Really beginner question
Exception in thread "main"
what is wrong with this?
While loop - Head's First Java example