wood burning stoves*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Interesting exception to overloading enum rule from Sierra Bates book Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Interesting exception to overloading enum rule from Sierra Bates book" Watch "Interesting exception to overloading enum rule from Sierra Bates book" New topic
Author

Interesting exception to overloading enum rule from Sierra Bates book

nico dotti
Ranch Hand

Joined: Oct 09, 2007
Posts: 124
Hello all. On page 65 of Bates and Sierra book there is an example enum where the getLidCode method is overloaded. There's a comment that says that <-- the semicolon is REQUIRED...
I just coded something similar that seems to work without the ';'. Granted I put the overloaded enum type first (their's has it last), but I didn't put a semicolon and it worked just fine. Here's the code:



Any comments or explanations?
[ November 14, 2007: Message edited by: nico dotti ]
ahmed yehia
Ranch Hand

Joined: Apr 22, 2006
Posts: 424
A semi colon is required to end enum Constant declarations when you have an enum body(i.e variables, methods, Constructors), Not when you have a Constant specific class body.

And you still have to provide it in you example:
SMALL(8,"Live a little why don't you!"); <-
nico dotti
Ranch Hand

Joined: Oct 09, 2007
Posts: 124
Thanks Ahmed...that makes sense to me. However, I didn't quite understand you're last comment - were you basically pointing out that my example itself confirms what you're saying given the ';' at the end?
ahmed yehia
Ranch Hand

Joined: Apr 22, 2006
Posts: 424
Yes, in your example you have an enum body, hence the semi colon is required.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Interesting exception to overloading enum rule from Sierra Bates book
 
Similar Threads
Question about enums and enhanced for
Enum Problem - Please help
Enum programs are not compiling in java5.0 compiler?
Enums...
use of " this " ...