enum within an enum

Discussion in 'Java' started by -, Jun 12, 2005.

  1. -

    - Guest

    public enum A {
    A1_ASC,
    A1_DSC,
    A2_ASC,
    A2_DSC;
    }


    If I access A1_ASC, I have to do A.A1_ASC.

    Is it possible to have a so called enum within an enum so that i can do a:

    A.ASC.A1
    A.ASC.A1
    A.DSC.A2
    A.DSC.A2
    -, Jun 12, 2005
    #1
    1. Advertising

  2. http://www.brayneychyled.com/helpoutsometimes.htm
    "-" <> wrote in message
    news:42abf517$...
    > public enum A {
    > A1_ASC,
    > A1_DSC,
    > A2_ASC,
    > A2_DSC;
    > }
    >
    >
    > If I access A1_ASC, I have to do A.A1_ASC.
    >
    > Is it possible to have a so called enum within an enum so that i can do a:
    >
    > A.ASC.A1
    > A.ASC.A1
    > A.DSC.A2
    > A.DSC.A2
    Sympatico Member, Jun 12, 2005
    #2
    1. Advertising

  3. -

    - Guest

    -, Jun 12, 2005
    #3
  4. -

    Wibble Guest

    - wrote:
    > public enum A {
    > A1_ASC,
    > A1_DSC,
    > A2_ASC,
    > A2_DSC;
    > }
    >
    >
    > If I access A1_ASC, I have to do A.A1_ASC.
    >
    > Is it possible to have a so called enum within an enum so that i can do a:
    >
    > A.ASC.A1
    > A.ASC.A1
    > A.DSC.A2
    > A.DSC.A2

    how about
    public class A {
    public static enum A1 {...}
    public static enum A2 {...}
    }
    Wibble, Jun 12, 2005
    #4
  5. -

    Wibble Guest

    Wibble wrote:
    > - wrote:
    >
    >> public enum A {
    >> A1_ASC,
    >> A1_DSC,
    >> A2_ASC,
    >> A2_DSC;
    >> }
    >>
    >>
    >> If I access A1_ASC, I have to do A.A1_ASC.
    >>
    >> Is it possible to have a so called enum within an enum so that i can
    >> do a:
    >>
    >> A.ASC.A1
    >> A.ASC.A1
    >> A.DSC.A2
    >> A.DSC.A2

    >
    > how about
    > public class A {
    > public static enum A1 {...}
    > public static enum A2 {...}
    > }

    Oops
    public class A {
    static enum ASC ...
    }
    Wibble, Jun 12, 2005
    #5
  6. -

    - Guest

    Wibble wrote:
    >> how about
    >> public class A {
    >> public static enum A1 {...}
    >> public static enum A2 {...}
    >> }

    >
    > Oops
    > public class A {
    > static enum ASC ...
    > }


    I tried that but instead of having the method accepting (A a) as the
    parameter, I must change it to 'method(A.ASC a)' and add another method
    'method(A.DSC a)' rather than having one method 'method(A a)'.
    -, Jun 13, 2005
    #6
  7. -

    - Guest

    - wrote:
    > Wibble wrote:
    >
    >>> how about
    >>> public class A {
    >>> public static enum A1 {...}
    >>> public static enum A2 {...}
    >>> }

    >>
    >>
    >> Oops
    >> public class A {
    >> static enum ASC ...
    >> }

    >
    >
    > I tried that but instead of having the method accepting (A a) as the
    > parameter, I must change it to 'method(A.ASC a)' and add another method
    > 'method(A.DSC a)' rather than having one method 'method(A a)'.


    nvm.. i get what you mean.
    -, Jun 13, 2005
    #7
    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. Jerminia
    Replies:
    3
    Views:
    624
    Roedy Green
    Oct 7, 2005
  2. Ernst Murnleitner

    How to enum an enum?

    Ernst Murnleitner, Nov 12, 2003, in forum: C++
    Replies:
    5
    Views:
    463
    Rolf Magnus
    Nov 13, 2003
  3. mrhicks
    Replies:
    2
    Views:
    417
    Dave Thompson
    Jun 10, 2004
  4. Randy
    Replies:
    1
    Views:
    516
    David Harmon
    Jan 7, 2006
  5. Randy
    Replies:
    2
    Views:
    361
    Randy Yates
    Jan 8, 2006
Loading...

Share This Page