Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Stand Alone Enums???

Reply
Thread Tools

Stand Alone Enums???

 
 
chris.allport@gmail.com
Guest
Posts: n/a
 
      02-21-2005
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!

 
Reply With Quote
 
 
 
 
Roland
Guest
Posts: n/a
 
      02-21-2005
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_/ /__/
/ \ /_/ / \
 
Reply With Quote
 
 
 
 
chris.allport@gmail.com
Guest
Posts: n/a
 
      02-21-2005
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.

 
Reply With Quote
 
chris.allport@gmail.com
Guest
Posts: n/a
 
      02-21-2005
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!

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
stand alone executable using pp doesn't stand alone Plotinus Perl Misc 2 12-17-2004 01:09 AM
Suite or stand alone? Caploc Firefox 2 11-10-2004 09:48 PM
IAS fails with certs from Stand Alone CA Harrison Midkiff Wireless Networking 2 07-22-2004 09:45 PM
Main Advantages i get when i do a stand alone app in .Net rather than in VB. Punya Narra ASP .Net 5 02-17-2004 12:02 PM
Install AD, DNS, DHCP on an isolated stand alone pc? Javier GP MCSE 5 09-30-2003 12:42 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57