File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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
 
 
subject: Semicolon after enum constant declaration?