File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes About Enum Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "About Enum" Watch "About Enum" New topic

About Enum

Ranch Hand

Joined: Oct 26, 2006
Posts: 58
Can we import an enum ?
if so isit same like importing a class or else any rules ?
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

Not an advanced question. Moving...

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

The best way to find this sort of thing out is to try it

The basic answer though is yes, you can import an enum.
Burkhard Hassel
Ranch Hand

Joined: Aug 25, 2006
Posts: 1274
Howdy BTR,

you can use import to import the enum per se or you can use import static to also import the fields of the enum.
For example if you have

in package "resources", then you can have in another package:

line 1 only works because of the 1st import, without import the line had to be
resources.Animal animal;

line 2 only works because of the 2nd import, without it had to be
main.animal = Animal.SNAKE;


all events occur in real time
I agree. Here's the link:
subject: About Enum
It's not a secret anymore!