• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Semicolon after enum constant declaration?

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Destiny's powerful hand has made the bed of my future. And this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic