This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Semicolon after enum constant declaration? 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 » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Semicolon after enum constant declaration?" Watch "Semicolon after enum constant declaration?" New topic
Author

Semicolon after enum constant declaration?

Kosta Servis
Greenhorn

Joined: Jul 21, 2007
Posts: 3
(SCJP -- Sierra & Bates pg65)

the code listing in that page reads:


pointing out that the semicolon is required after the final declaration. However in another book I have read that you can have a comma instead for convenience. Is that true? If yes is it acceptable in the exam?
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
When you have body in the enum declaration, semicolon is mandatory (you can't
avoid otherwise compiler error). For exam you have to watch that.


Welcome to JavaRanch!

Thanks,


cmbhatt
Kosta Servis
Greenhorn

Joined: Jul 21, 2007
Posts: 3
Edit: I suppose the real question is : "When i submit code in the exam is it compiled by javac or is it text matched somehow?"
[ July 21, 2007: Message edited by: Kosta Servis ]
Padma Asrani
Ranch Hand

Joined: Mar 22, 2007
Posts: 111
Hi Kosta


pointing out that the semicolon is required after the final declaration. However in another book I have read that you can have a comma instead for convenience. Is that true? If yes is it acceptable in the exam?


I guess you misunderstood it. if you have constant specific class bodies for more than one constants then you need to separate different constants with "," and after the last constant specific class body you have to put a ";" to mark the end of enum declaration. For example refer the code



Regards
Padma
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Semicolon after enum constant declaration?
 
Similar Threads
Updated K&B 5 Errata - 4/16
Enum doubt
Doubt regarding enum
Hard Exam question
Optional semicolon in enumerated type declaration "when no other declarations for thi