Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is Enum?

 
Mrutyunjaya Sahu
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey all,

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

Thanks in advance....

 
Stephan van Hulst
Bartender
Posts: 6327
78
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also see the oracle tutorial about enums.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic