aspose file tools*
The moose likes Beginning Java and the fly likes Enums in Java needed Clarity Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Enums in Java needed Clarity" Watch "Enums in Java needed Clarity" New topic
Author

Enums in Java needed Clarity

Chand Prem
Greenhorn

Joined: Nov 26, 2012
Posts: 1
Hi

I want to know how to validate users input (for ex Month name) using enums in Java. Can some one provide a examples or a link explaining it.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39834
    
  28
Welcome to the Ranch

Why do you think enums are any good for validating inputs?
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11479
    
  16

I think this is a common mistake many people make. They ask a question along the lines of "How do I use X to do Y?".

The better question would be "What is the correct way to do Y?". By already deciding what technology to use before you think about what the problem you are trying to solve is, you box yourself into a corner.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
wood burning stoves
 
subject: Enums in Java needed Clarity