Results 1 to 5 of 5
  1. #1
    XmisterIS is offline Member
    Join Date
    Aug 2010
    Posts
    35
    Rep Power
    0

    Default Struggling with enum!

    I feel a little silly posting about something as simple as an enum .. but I just can't get the syntax right!

    All I'm trying to do is:

    Java Code:
    public final enum DeltaEnum { POSITIVE = 1, NEGATIVE = -1; }
    This has the same syntax as examples I've seen posted on the web, but the compiler says ',', '}', or ';' expected.

    Confused! :confused:

    (And a little embarrassed :o ... !)

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    If you see a web example of a Java 1.5 or above enum showing code like that, I'd like to see the website, because you're code is very wrong (= 1?) and you must be looking at bad examples. Please go to the Sun/Oracle tutorials and study those pages: enum tutorial



    Best of luck.

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,792
    Rep Power
    19

    Default

    That looks (sort of, if you squint) like C++ enums, where you can assign numeric values to them.

    But yes, that's not Java syntax.

  4. #4
    XmisterIS is offline Member
    Join Date
    Aug 2010
    Posts
    35
    Rep Power
    0

    Default

    Quote Originally Posted by Fubarable View Post
    If you see a web example of a Java 1.5 or above enum showing code like that, I'd like to see the website, because you're code is very wrong (= 1?) and you must be looking at bad examples. Please go to the Sun/Oracle tutorials and study those pages: enum tutorial



    Best of luck.
    Thanks for the link, I've fixed it using (1) and (-1) instead of =1 and =-1.

    FYI, the site I was looking at was: Java enum example

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,792
    Rep Power
    19

    Default

    Yep.
    The first example there is C++!

    What a twit the poster on that site is.

    One more reason why using the Sun/Oracle site for finding out how to do things in Java si your best bet.

Similar Threads

  1. Struggling with AlphaComposite .. please help me
    By jeshmal4u in forum Java 2D
    Replies: 3
    Last Post: 03-08-2010, 05:11 AM
  2. enum
    By billq in forum New To Java
    Replies: 3
    Last Post: 01-03-2010, 08:38 PM
  3. Struggling with OnKeyPressed Event in java
    By Camzie in forum NetBeans
    Replies: 2
    Last Post: 12-01-2009, 07:58 AM
  4. Struggling with java .ini files
    By Camzie in forum NetBeans
    Replies: 6
    Last Post: 11-24-2009, 03:13 PM
  5. struggling with creating a GUI
    By tuwannu in forum Advanced Java
    Replies: 2
    Last Post: 12-01-2008, 02:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •