| Author |
enums and protected modifier
|
Sasha Ruehmkorf
Ranch Hand
Joined: Mar 29, 2007
Posts: 115
|
|
Hi. I just tried to declare a member of an enum protected and it worked. Protected-access would be exactly the same as the default-access as there will never be a subclass from an enum, is this right?
|
 |
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
|
|
|
Sounds right to me.
|
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
|
 |
Trond Valen
Greenhorn
Joined: Aug 31, 2007
Posts: 1
|
|
I partly agree, it is the same as default access, but why is the protected modifier allowed for enum variables when enums can't be "subclassed"? I thought the main principle was that modifiers that make no sense or introduce redundancy are not allowed, just like classes can't be protected or private. In this case, protected is redundant, because it's the same as having no modifiers (default access). But then again, protected variables are allowed in final classes, and enums can be seen as a special kind of final classes. This brings me to another question: can you always choose access modifiers for class and instance variables regardless of which modifiers the class has? [ August 31, 2007: Message edited by: Trond Valen ]
|
 |
 |
|
|
subject: enums and protected modifier
|
|
|