*
The moose likes Beginning Java and the fly likes Getting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Getting "Class, Interface or Enum expected" at the end of my code." Watch "Getting "Class, Interface or Enum expected" at the end of my code." New topic
Author

Getting "Class, Interface or Enum expected" at the end of my code.

Toshiro Hitsuguya
Greenhorn

Joined: May 15, 2009
Posts: 19
Hey, you guys have been extremely helpful so far.

I am having a problem getting part of my code to compile. At the very end of the code I am getting "Class, Interface, or Enum expected" at the end of my code. I tried to add another } but that didn't work. I have part of my code finished so far.




Toshiro Hitsuguya
Greenhorn

Joined: May 15, 2009
Posts: 19
Never mind just fixed it.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38036
    
  22
Well done fixing it ( ) ; I probably know what you did without even looking at your code, but for the benefit of other readers, please tell us briefly what the problem was.
Toshiro Hitsuguya
Greenhorn

Joined: May 15, 2009
Posts: 19
Sure. Thanks. It's very simple. I went through the number of } and found that I had too many. Simple error. Erased one and worked fine.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38036
    
  22
That's what I though. "class interface or enum expected" at the end of the class means too many }
The same error at the beginning of the class usually means
  • A spelling error eg Class or clas
  • Something other than package declarations or imports before the class declaration
  • A formatting error like publicclass instead of public class
  •  
    It is sorta covered in the JavaRanch Style Guide.
     
    subject: Getting "Class, Interface or Enum expected" at the end of my code.
     
    Similar Threads
    Having Trouble Referencing a Method from Anonther Method in Another Class
    Getting Incompatible Types java.lang.String
    Problem Adding Different "Book" Objects Into A "Library" Array
    Getting a lot of "method cannot be applied to (java.lang.string)"
    Array List is Printing Out the Exact Same Thing