This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About Enum

 
srinivas.b
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can we import an enum ?
if so isit same like importing a class or else any rules ?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not an advanced question. Moving...
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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;


Yours,
Bu.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic