Results 1 to 4 of 4
Thread: public static enum vs enum class
- 08-27-2011, 10:50 AM #1
Member
- Join Date
- Aug 2010
- Location
- Leuven, Belgium
- Posts
- 86
- Rep Power
- 0
- 08-27-2011, 10:58 AM #2
Senior Member
- Join Date
- Oct 2010
- Location
- Germany
- Posts
- 785
- Rep Power
- 12
You have direct access to the (private) static members of the outer class (when using a inner static enum)
- 08-27-2011, 12:08 PM #3
Member
- Join Date
- Aug 2010
- Location
- Leuven, Belgium
- Posts
- 86
- Rep Power
- 0
Hi,
That one i know, but the question is more, when do i use an enum class and when a static enum.
what are the (dis)avantages of the one vs the other ?
thanks
- 08-30-2011, 11:45 AM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 13,541
- Rep Power
- 27
Neatness mainly.
And logical grouping.
If the enum is small and associated purely with what is going on in the outer class then maybe keep it in there, but if it's for use outside the class, and/or has a load of its own code then I'd consider sticking it in its own file. Unless (as said above) you need access to some of the data in the outer class.
Similar Threads
-
how to use this enum class
By thorbcn in forum New To JavaReplies: 1Last Post: 07-04-2011, 03:29 AM -
Class enum expected
By Tyre in forum New To JavaReplies: 10Last Post: 04-16-2011, 08:25 PM -
Setting values from One Enum type to another enum type.
By reach2sudhakar in forum New To JavaReplies: 3Last Post: 09-23-2010, 07:02 PM -
class, interface or enum expected?
By Addez in forum New To JavaReplies: 2Last Post: 08-26-2009, 08:54 PM -
E:\IT 215 Java Programming\public class Inventory.java:39: class, interface, or enum
By tlouvierre in forum New To JavaReplies: 14Last Post: 05-28-2009, 06:44 AM
Bookmarks