This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes What is Enum? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "What is Enum?" Watch "What is Enum?" New topic
Author

What is Enum?

Mrutyunjaya Sahu
Greenhorn

Joined: Oct 02, 2011
Posts: 1
Hey all,

I'm beginner to Java, could anybody explain about Enum with an example please?

Thanks in advance....

Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3615
    
  14

Hello, welcome to CodeRanch!

Enums are lists of constants. When you need a predefined list of values which do not represent some kind of numeric or textual data, you should use an enum. For instance, in a chess game you could represent the different types of pieces as an enum:
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Also see the oracle tutorial about enums.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
 
Consider Paul's rocket mass heater.
 
subject: What is Enum?