This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
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

Win a copy of Elasticsearch in Action this week in the Big Data forum!
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 ';' 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: 9048

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 ";".

[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.
wood burning stoves
subject: Java Code Error