One Enum per File?

Discussion in 'Java' started by Joan, Jul 18, 2005.

  1. Joan

    Joan Guest

    Since an Enum is a class, is it expected that
    you put only one Enum in a file? This could
    make for a whole lot of files for some applications.
     
    Joan, Jul 18, 2005
    #1
    1. Advertising

  2. Joan

    Roedy Green Guest

    On Mon, 18 Jul 2005 16:07:44 -0500, "Joan" <> wrote
    or quoted :

    >Since an Enum is a class, is it expected that
    >you put only one Enum in a file? This could
    >make for a whole lot of files for some applications.


    One file per enum usually works out best. If the enum is not public,
    you can make it a top level non-nested class with package visibility

    --
    Bush crime family lost/embezzled $3 trillion from Pentagon.
    Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
    http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm

    Canadian Mind Products, Roedy Green.
    See http://mindprod.com/iraq.html photos of Bush's war crimes
     
    Roedy Green, Jul 19, 2005
    #2
    1. Advertising

  3. Joan

    Jim McMaster Guest

    At 7/18/2005 3:07:44 PM, Joan wrote:

    > Since an Enum is a class, is it expected that
    > you put only one Enum in a file? This could
    > make for a whole lot of files for some applications.


    The enum defines the structure of the enum type, and also the
    definitions of all the member types of the enum. You can have:

    public enum MyEnum {
    MyType1, MyType2, MyType3
    }

    to define an enum with three types.

    --
    Jim McMaster
    mailto:
     
    Jim McMaster, Jul 19, 2005
    #3
  4. Joan

    Dale King Guest

    Roedy Green wrote:
    > On Mon, 18 Jul 2005 16:07:44 -0500, "Joan" <> wrote
    > or quoted :
    >
    >
    >>Since an Enum is a class, is it expected that
    >>you put only one Enum in a file? This could
    >>make for a whole lot of files for some applications.

    >
    >
    > One file per enum usually works out best. If the enum is not public,
    > you can make it a top level non-nested class with package visibility


    I would say that it would probably be rare that you want a top-level
    enum. Usually the enum is going to be associated with some API and
    defined in that class or intreface.

    I've actually defined an enum nested within another enum.


    --
    Dale King
     
    Dale King, Jul 19, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?S01aX3N0YXRl?=

    Quick one - Is SESSION per browser instance or per IP Address?

    =?Utf-8?B?S01aX3N0YXRl?=, Apr 4, 2006, in forum: ASP .Net
    Replies:
    7
    Views:
    5,949
    gerry
    Apr 10, 2006
  2. Razvan
    Replies:
    1
    Views:
    443
    tony vee
    Sep 10, 2004
  3. Replies:
    5
    Views:
    2,634
  4. Replies:
    0
    Views:
    372
  5. Randy Kramer
    Replies:
    2
    Views:
    430
    Randy Kramer
    Jan 12, 2007
Loading...

Share This Page