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 What is Enum? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "What is Enum?" Watch "What is Enum?" New topic

What is Enum?

Mrutyunjaya Sahu

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

Joined: Sep 20, 2010
Posts: 3678

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.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: What is Enum?