aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes enum - compile or not 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 "enum - compile or not " Watch "enum - compile or not " New topic
Author

enum - compile or not

ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830


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

Joined: Jul 11, 2003
Posts: 1392
will this code give any compilation error ? ( because have ; )

No compilation error.
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
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

Joined: Oct 11, 2004
Posts: 3830
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

Joined: Jun 04, 2002
Posts: 3212
    
    6
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


Free SCDJWS 5.0 Study Guide - SCDJWS 5.0 Quiz (How to get SCDJWS 5.0 Quiz)
Java Platform, Enterprise Edition 6 Web Services Developer Certified Expert Exam Study Guide and Quiz
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
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

Joined: Oct 11, 2004
Posts: 3830
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 .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: enum - compile or not