Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Java
enums and modifiers
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="richnjones, post: 3139299"] Hello all, I was messing around with enums and am confused about the modifiers I can apply. I am using Eclipse and am not sure if I am misunderstanding the error. Consider this enum enum Planets {Mercury, Venus} I can put private/protected/public in front of it. At the moment I consider it to have package access. This makes perfect sense I can also add static in front of it. Enum is a class that extends Object so that kind of makes sense. However I cannot add final in front of it. Now I dont believe you can extends enums (why would you want to) so having final might seem a little pointless but i do not see why you cannot have it for completeness. (You can add final to variables in Iiterfaces which are implicitly final) Also and more confusingly when I put final in front of it then Eclipse says it is an invalid modifier and that I can only have private/protected/public/ abstract/static. When I put abstract in front I get a compile error. Is Eclipse wrong? Can you put an abstract in front of enums in some cases? Is there any reason you cannot put final in front? (Assuming you can use abstract then i can see why final isnt allowed). What use would an abstract have? abstract enum Planet {Mercury, Venus} //does not compile Any help is greatly appreciated Thanks R [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Java
enums and modifiers
Top