File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Semicolon after enum constant declaration?

 
Kosta Servis
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(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
Posts: 1710
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
Kosta Servis
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 111
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic