What happened to Enum?

Discussion in 'Java' started by Rhino, Oct 8, 2009.

  1. Rhino

    Rhino Guest

    I'm just starting to get back into Java after an extended absence of about 3
    years working on other things and I'm bumping into some things that have me
    confused.

    I've installed Eclipse 3.5.1 and the 1.6 level version of the JDK. When I
    try to create an Enum, I get strange messages from Eclipse. I'm getting the
    impression that Enums, which were new in JDK 1.4 if I recall correctly, are
    now gone: is that right?

    Can someone fill me in on what happened to them? I was just starting to use
    these routinely when I detoured into other things so I suspect I've missed
    some major developments in Java. If Enums are indeed gone, what is the "new
    and better way" to accomplish the same thing?

    --
    Rhino
    Rhino, Oct 8, 2009
    #1
    1. Advertising

  2. Rhino

    Lew Guest

    Rhino wrote:
    > I've installed Eclipse 3.5.1 and the 1.6 level version of the JDK. When I
    > try to create an Enum, I get strange messages from Eclipse. I'm getting the
    >


    Post code and the "strange" messages, copied and pasted, not
    paraphrased. We can then explain them. I'm guessing you tried to use
    the 'Enum' class directly instead of the 'enum' keyword.

    > impression that Enums, which were new in JDK 1.4 if I recall correctly, are
    > now gone: is that right?
    >


    No, it isn't.

    Enums were new in Java 5, not 1.4.

    The tutorial covers them in
    <http://java.sun.com/docs/books/tutorial/java/javaOO/enum.html>

    Enums are declared using the keyword 'enum'.

    public enum RGB
    {
    RED, GREEN, BLUE;
    }

    Before concluding that enums "are now gone", you should read the
    documentation. For fundamental questions, I usually start with the
    tutorials before moving on to advanced literature or newsgroups.

    The JLS covers them in excruciating detail in
    <http://java.sun.com/docs/books/jls/third_edition/html/
    classes.html#8.9>

    Also, GIYF.

    --
    Lew
    Lew, Oct 8, 2009
    #2
    1. Advertising

  3. Rhino

    Arne Vajhøj Guest

    Rhino wrote:
    > I'm just starting to get back into Java after an extended absence of about 3
    > years working on other things and I'm bumping into some things that have me
    > confused.
    >
    > I've installed Eclipse 3.5.1 and the 1.6 level version of the JDK. When I
    > try to create an Enum, I get strange messages from Eclipse. I'm getting the
    > impression that Enums, which were new in JDK 1.4 if I recall correctly, are
    > now gone: is that right?
    >
    > Can someone fill me in on what happened to them? I was just starting to use
    > these routinely when I detoured into other things so I suspect I've missed
    > some major developments in Java. If Enums are indeed gone, what is the "new
    > and better way" to accomplish the same thing?


    Enums has not been removed from Java.

    Try post the code you are trying to compile and the error message
    you get, then hopefully someone can tell you what the problem is.

    Arne
    Arne Vajhøj, Oct 8, 2009
    #3
  4. Rhino

    Roedy Green Guest

    On Thu, 8 Oct 2009 17:13:47 -0400, "Rhino"
    <> wrote, quoted or indirectly
    quoted someone who said :

    >which were new in JDK 1.4 if I recall correctly, are
    >now gone: is that right?


    There are alive and well. See http://mindprod.com/jgloss/enum.html

    You might have the compiler configured in your IDE to some old
    version.
    --
    Roedy Green Canadian Mind Products
    http://mindprod.com

    I advocate that super programmers who can juggle vastly more complex balls than average guys can, should be banned, by management, from dragging the average crowd into system complexity zones where the whole team will start to drown.
    ~ Jan V.
    Roedy Green, Oct 9, 2009
    #4
  5. Rhino

    Roedy Green Guest

    On Thu, 8 Oct 2009 17:13:47 -0400, "Rhino"
    <> wrote, quoted or indirectly
    quoted someone who said :

    >I'm just starting to get back into Java after an extended absence of about 3
    >years working on other things and I'm bumping into some things that have me
    >confused.
    >
    >I've installed Eclipse 3.5.1 and the 1.6 level version of the JDK. When I
    >try to create an Enum, I get strange messages from Eclipse. I'm getting the
    >impression that Enums, which were new in JDK 1.4 if I recall correctly, are
    >now gone: is that right?
    >
    >Can someone fill me in on what happened to them? I was just starting to use
    >these routinely when I detoured into other things so I suspect I've missed
    >some major developments in Java. If Enums are indeed gone, what is the "new
    >and better way" to accomplish the same thing?


    Note, the keyword is enum not Enum. It is implemented under the hood
    by extending the Enum class.
    --
    Roedy Green Canadian Mind Products
    http://mindprod.com

    I advocate that super programmers who can juggle vastly more complex balls than average guys can, should be banned, by management, from dragging the average crowd into system complexity zones where the whole team will start to drown.
    ~ Jan V.
    Roedy Green, Oct 9, 2009
    #5
  6. Rhino

    Dave Searles Guest

    Peter Duniho wrote:
    > On Thu, 08 Oct 2009 14:13:47 -0700, Rhino
    > <> wrote:
    >
    >> [...]
    >> I've installed Eclipse 3.5.1 and the 1.6 level version of the JDK. When I
    >> try to create an Enum, I get strange messages from Eclipse.

    >
    > Such as?
    >
    >> I'm getting the
    >> impression that Enums, which were new in JDK 1.4 if I recall
    >> correctly, are
    >> now gone: is that right?

    >
    > No, that's not right. Are you sure your project in Eclipse is properly
    > configured to target Java 1.6, rather than some earlier version? It's
    > hard to imagine you'd have it configured for pre-1.4, but based on the
    > limited information you've provided so far, that's the only thing that
    > comes to mind.
    >
    > Of course, part of the problem is that you're very unspecific about what
    > problem you're actually seeing. I suppose it's possible you've just
    > forgotten how to use enums in Java properly, and the errors you're
    > getting are just plain old syntax errors of some sort.


    No. None of the nasty things that you have said or implied about Rhino
    are true.




    Just kidding. :)
    Dave Searles, Oct 9, 2009
    #6
    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. -

    enum within an enum

    -, Jun 12, 2005, in forum: Java
    Replies:
    6
    Views:
    540
  2. Jerminia
    Replies:
    3
    Views:
    624
    Roedy Green
    Oct 7, 2005
  3. Ernst Murnleitner

    How to enum an enum?

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

Share This Page