This week's giveaway is in the Groovy forum.
We're giving away four copies of Groovy Fundamentals video training course and have Ken Kousen 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 Groovy Fundamentals video training course this week in the Groovy 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: 9102

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