It's not a secret anymore!
The moose likes Beginning Java and the fly likes Same old problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Same old problems" Watch "Same old problems" New topic

Same old problems

Dwayne Loving

Joined: May 22, 2005
Posts: 9
Seems like I can't escape the problem of having 1 or 2 errors when I compile my prgram. Here's what I have:
public class calculateFunction
public int calculateValue (int x)

int y=0
y=(int)(x+(x*x) + Math.pow(2,x));
return y;

public void printStars ()
for (int j; j < 10; ++j)

int y = calculateValue(j);
System.out.println("PrintFor: +j");
for (int I=0;i<y;i++)
System.out.println ("\n\n");

public static void main (String[] args)
calculateFunction cal = new calculateFunction ();
The error message I receive is:

any ideas as to why this error continously comes up?

Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

The semicolon ( that belongs at the end of the previous line is missing.

[Jess in Action][AskingGoodQuestions]
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
For future reference, Sun's compiler shows a caret (^) underneath the line of code to indicate where it encountered a problem. Sometimes the actual cause of the error is before this. In this case, as EFH pointed out, the missing semicolon that the error message is complaining about should go on the previous line.

Get used to having error messages the first time you compile a program. I am willing to bet that most programmers see them often. The trick is to learn what the error message means so it can help you find the problem and fix it. In this case, the moral of the story is that you should look at the lines above where the actual error occurs.



Java API Documentation
The Java Tutorial
I agree. Here's the link:
subject: Same old problems
It's not a secret anymore!