• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

enum - compile or not

 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


will this code give any compilation error ? ( because have ; )

I am asking this because this is from a tutorial ( not mine ) ...

Thanks .
[ March 04, 2005: Message edited by: rathi ji ]
 
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
will this code give any compilation error ? ( because have ; )

No compilation error.
 
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nope. No compile error. Here's demo, showing it doesn't mess up the list or anything. You need the semi-colon if you're going to add other stuff to the enum definition (didn't show that, should be in the what's new page you already have url for).


 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In this link only there are two example , one is with ; & one is wiithout ...

http://java.sun.com/j2se/1.5.0/docs/guide/language/enums.html

both has some extra members after the enum constants .. both are right or ...

Thanks .
 
Bartender
Posts: 3904
43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi !

This code is pretty legal.

The ';' semi-colon is not needed here, but it does not cause any problems.

You can try also something like :



It compiles just fine too.

regards,
MZ
 
Carol Enderlin
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't see what examples you are asking about one with ; and one without, both with extra members. Could you be more specific?

Originally posted by rathi ji:
In this link only there are two example , one is with ; & one is wiithout ...

http://java.sun.com/j2se/1.5.0/docs/guide/language/enums.html

both has some extra members after the enum constants .. both are right or ...

Thanks .

 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK sorry Carol ,
Actually it was a class that is having other statements after enum declaration , so need for ; after last enum constant .

Thanks a lot .
 
Where all the women are strong, all the men are good looking and all the tiny ads are above average:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic