Exposing an Enum (revisited)

Z

zacks

I am using JDK 1.5 with NetBeans 5.5. I have a project that contains a
class that has a public enum. I would like to reference this enum not
only in another class in the same project, but I would also like to
reference the enum in another project. I can get the project that
contains the enum to be referenced in the other project and all classes
are available, EXCEPT the enums!!! I can't even reference these enums
in a different class IN THE SAME PROJECT!!

How do I expose public enums across classes and across projects?
 
D

Daniel Pitts

I am using JDK 1.5 with NetBeans 5.5. I have a project that contains a
class that has a public enum. I would like to reference this enum not
only in another class in the same project, but I would also like to
reference the enum in another project. I can get the project that
contains the enum to be referenced in the other project and all classes
are available, EXCEPT the enums!!! I can't even reference these enums
in a different class IN THE SAME PROJECT!!

How do I expose public enums across classes and across projects?
Enums are the same as classes. If they belong to another class, then
you need to use the classes name in the namespace:

public class MyClass {
public enum MyEnum {
value1, value2;
}
/* This works because of scope */
MyEnum value;
}

public class MyOtherClass {
/* need MyClass. because of scope */
MyClass.MyEnum value;
}
 
Z

zacks

Daniel said:
Enums are the same as classes. If they belong to another class, then
you need to use the classes name in the namespace:

public class MyClass {
public enum MyEnum {
value1, value2;
}
/* This works because of scope */
MyEnum value;
}

public class MyOtherClass {
/* need MyClass. because of scope */
MyClass.MyEnum value;
}

I think I tried every combination trying to get that to work except
that one! It appears to work. Thanks.
 
D

Daniel Pitts

I think I tried every combination trying to get that to work except
that one! It appears to work. Thanks.
Isn't that the way it always works?

Cheers,
Daniel.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top