This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes Help with Errors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Help with Errors" Watch "Help with Errors" New topic
Author

Help with Errors

Mike Meakin
Ranch Hand

Joined: Dec 30, 2004
Posts: 88
Can anyone tell me why I have got these errors:

"Applet2.java": Error #: 204 : illegal start of expression at line 92, column 70
"Applet2.java": Error #: 206 : malformed expression at line 92, column 15

Heres the code:

Steve Morrow
Ranch Hand

Joined: May 22, 2003
Posts: 657

Which one is line 92?

Also, it will help you to follow this: Code Conventions for the Java� Programming Language
Jon Egan
Ranch Hand

Joined: Mar 24, 2004
Posts: 83
I don't have a decent editor with me at the moment, so I can't identify which line is 92 without a lot of manual manipulation of the code after copying and pasting it.... but here are some things I've spotted:

- there are some strange comments going on above the constructor and the init() method - comments start with // for a comment that extends to the end-of-line, or with /* for a comment that extends to the next */ You seem to be mixing these styles, although my best guess is that the way you've done it is working, and is not the problem

- you have a call to "enabeEvents", that is probably supposed to be "enableEvents" - again, not going to be the source of your compiler errors.... yet - this would come up after it was able to successfully parse your code, so you have to get past the existing problem

- you have some "stray" semicolons in the frame.setLocation() method call - and there's also a problem with the parentheses in this method call.

good luck.

-- Jon
Jon Egan
Ranch Hand

Joined: Mar 24, 2004
Posts: 83
Michael,

I absolutely agree with Steve's suggestion that you learn and try to adopt Sun's coding style standards - most Java developers stick to it to some degree or another, which means:

- once you're used to it, you'll be better able to read the code of all those "conforming" programmers out there

- the vast majority of other Java programmers will be more able to help you with, and later maintain, your code - without having to run your code through a source code beautifier first

-- Jon
Timmy Marks
Ranch Hand

Joined: Dec 01, 2003
Posts: 226
You have a ; too many in the line about 6 lines from the bottom:


frame.setLocation((d.width - frame.getSize().width)); / 2, (d.height - frame.getSize() .height) /2);
Mike Meakin
Ranch Hand

Joined: Dec 30, 2004
Posts: 88
This is line 92/93:
frame.setLocation((d.width - frame.getSize().width)); / 2,
(d.height - frame.getSize() .height) /2));

Removing a ; does not solve the problem.
[ May 11, 2005: Message edited by: Michael Munro ]
Steve Morrow
Ranch Hand

Joined: May 22, 2003
Posts: 657

Removing a ; does not solve the problem.
I would imagine not. It looks like you're trying to comment out the last half of that statement (after the first semicolon), but you've only got one slash. Comments need two slashes.Once you have that semicolon, the compiler expects you to have reached the end of the statement and thinks the single slash is the start of your next statement (which, of course, causes it to unceremoniously barf).
 
 
subject: Help with Errors