• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Same old problems

 
Dwayne Loving
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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);
y/=10;
System.out.println("PrintFor: +j");
for (int I=0;i<y;i++)
System.out.print("*");
System.out.println ("\n\n");
}
}

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




any ideas as to why this error continously comes up?

Thanks,
Dwayne
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The semicolon ( that belongs at the end of the previous line is missing.
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

HTH

Layne
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic