• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

enum - compile or not

 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • 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 ]
 
Joyce Lee
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
will this code give any compilation error ? ( because have ; )

No compilation error.
 
Carol Enderlin
drifter
Ranch Hand
Posts: 1364
  • Mark post as helpful
  • send pies
  • 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: 3830
  • Mark post as helpful
  • send pies
  • 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 .
 
Mikalai Zaikin
Ranch Hand
Posts: 3367
11
  • Mark post as helpful
  • send pies
  • 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
Ranch Hand
Posts: 1364
  • Mark post as helpful
  • send pies
  • 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: 3830
  • Mark post as helpful
  • send pies
  • 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 .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic