Stand Alone Enums???

Discussion in 'Java' started by chris.allport@gmail.com, Feb 21, 2005.

  1. Guest

    I am trying to "globally" declare an enum so I can use it across a
    large application. This is an example of what I have tried:


    /** File: TestEnum.java ********/
    public enum TestEnum {
    ONE,
    TWO,
    THREE,
    FOUR;
    }


    /** File: TestClass.java **********/
    public class TestClass {
    TestEnum number;

    public void setNum(TestEnum num) { number = num; }
    public TestClass getNum() { return number; }

    }

    --

    The TestEnum is not being recognized as a valid type ("cannot find
    symbol").

    Any ideas on a good implementation of this?

    Thanks in advance!
    , Feb 21, 2005
    #1
    1. Advertising

  2. Roland Guest

    On 21-2-2005 17:51, wrote:

    > I am trying to "globally" declare an enum so I can use it across a
    > large application. This is an example of what I have tried:
    >
    >
    > /** File: TestEnum.java ********/
    > public enum TestEnum {
    > ONE,
    > TWO,
    > THREE,
    > FOUR;
    > }
    >
    >
    > /** File: TestClass.java **********/
    > public class TestClass {
    > TestEnum number;
    >
    > public void setNum(TestEnum num) { number = num; }
    > public TestClass getNum() { return number; }

    ^^^^^^^^^
    public TestEnum getNum() { return number; }

    >
    > }
    >
    > --
    >
    > The TestEnum is not being recognized as a valid type ("cannot find
    > symbol").
    >
    > Any ideas on a good implementation of this?
    >
    > Thanks in advance!
    >

    Return type of getNum() should be TestEnum.

    If TestClass.java still doesn't compile (if you still get "cannot find
    symbol"), specify your classpath with -classpath option, e.g.:
    javac -classpath . TestClass.java

    HTH,
    --
    Regards,

    Roland de Ruiter
    ___ ___
    /__/ w_/ /__/
    / \ /_/ / \
    Roland, Feb 21, 2005
    #2
    1. Advertising

  3. Guest

    Sorry, that was just a typo.

    Still not working.

    I created a third file "Thing.java" that implements a simple class and
    create one in "TestClass." This object is found. The "enum" still is
    not.
    , Feb 21, 2005
    #3
  4. Guest

    Hmm.. Nevermind. All of the sudden, it is compiling and working!? Of
    course, I have NO idea what I changed, because those files compare the
    same.

    Thanks for the assistance!
    , Feb 21, 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. Punya Narra
    Replies:
    5
    Views:
    1,671
    Itai Raz
    Feb 17, 2004
  2. greg
    Replies:
    1
    Views:
    257
    Peter Strøiman
    Oct 28, 2003
  3. Tom Hartnett

    how to create stand-alone page in VS

    Tom Hartnett, Nov 7, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    931
    Keith
    Nov 7, 2003
  4. GS
    Replies:
    1
    Views:
    694
    Nanda Lella[MSFT]
    Apr 13, 2006
  5. Plotinus
    Replies:
    2
    Views:
    277
    Tad McClellan
    Dec 17, 2004
Loading...

Share This Page