Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

So exhausted...anyone there to help?

 
N. Gonzalez
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
remove the additional closing brace '}' from the end of Student class and it compiles OK
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic