wood burning stoves
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 OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 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: 4112
    
  19

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:


The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What is Enum?
 
It's not a secret anymore!