my dog learned polymorphism
The moose likes Beginning Java and the fly likes Question about Java constants and enums Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Question about Java constants and enums" Watch "Question about Java constants and enums" New topic

Question about Java constants and enums

Brian Legg
Ranch Hand

Joined: Nov 07, 2008
Posts: 488
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?


~Currently preparing for SCJP6
BV Boose
Ranch Hand

Joined: Jul 26, 2008
Posts: 33
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.
I agree. Here's the link:
subject: Question about Java constants and enums
It's not a secret anymore!