wood burning stoves 2.0*
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 Murach's Java Servlets and JSP this week in the Servlets 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: 3573
    
  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.
 
Don't get me started about those stupid light bulbs.
 
subject: What is Enum?
 
Similar Threads
retrieve enumeration datatype into jsp
How to define constants for several classes?
Creating SingleTON without static variables
what results byte code in java
Enum Problem