File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes So exhausted...anyone there to help? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "So exhausted...anyone there to help? " Watch "So exhausted...anyone there to help? " New topic

So exhausted...anyone there to help?

N. Gonzalez

Joined: Jul 17, 2005
Posts: 29
What does 'class' or 'interface' expected error mean?

I tried to follow advice about having separate variables --one static and one not-- so that my student id would increment, and now my class file that compiled before won't compile and I get that error. Then I removed the getter/setter for the student id instance variables.

Feel like I've taken steps back because I can't continue to work on my Student Test file until this Student class file compiles again.

I'm trying different things and getting nowhere...please help.

Working on this for two days and feeling stupider by the moment.

Here's my code again:

Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

This is a bit too much code for me to look at right now, but I'll tell you what the error message means: it means that after the first class definition in a file, the compiler found something besides the words "class" or "interface" . This almost always a "}" character. The real problem is just that your curly braces aren't balanced -- you've got an extra close-brace at the end of your class.

Using a good programmer's editor is the best way to avoid this kind of problem, by the way -- the editor would show you the problem immediately by pointing out the non-matching braces.

[Jess in Action][AskingGoodQuestions]
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
remove the additional closing brace '}' from the end of Student class and it compiles OK
I agree. Here's the link:
subject: So exhausted...anyone there to help?
It's not a secret anymore!