• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about Java constants and enums

 
Brian Legg
Ranch Hand
Posts: 488
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a more elegant way to make static final Strings?

I have a whole list of user options as Strings and I am keeping them as constants so that if at a later date I want to change an option I can do it in one place. I know that enums are great for ints and stuff like that, but right now I have a long list of static final Strings and a big line of if then else statements checking the user input against the available Strings.

Any options to make the code cleaner?

Thanks!
 
BV Boose
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
do you have an example of what these choices look like? Can they be broken down into categories? or will every user input result in a unique response? What about .property or .xml files? You can use enums for more then just ints.
http://java.sun.com/j2se/1.5.0/docs/guide/language/enums.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic