• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What does class or interface expected error mean?

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:


 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
remove the additional closing brace '}' from the end of Student class and it compiles OK
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry the solution is right there, so you need to check all the braces and semi-colons.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
same as above, all your braces need to get checked to make sure things are opening and closing properly.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Always make sure to format your code! Makes life a lot easier
 
Sheriff
Posts: 5555
326
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Given that it's been 12 years since N. Gonzalez asked this question, I doubt he or she is still waiting on the answer.
 
reply
    Bookmark Topic Watch Topic
  • New Topic