• Post Reply Bookmark Topic Watch Topic
  • New Topic

enums  RSS feed

 
marioso gee
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I just wondered how top notch java programmers deal with no 'enum' feature.
Is there an easy solution or is it best to just stick with...


etc.
thanks
marioso
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can roll yer own type safe enums in Java. Note that your example above is not type safe, as you're using an int to represent another data type - a direction.
Also, Java 1.5 introduces a new type to the J2SE - enums.
Moving this to the Intermediate forum...
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A roll-yer-own type safe enum in Java of what you've proposed above might look something like the following.Perhaps the example is enough of an explanation. If not, do ask.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dag nabbit! Now, I see you've gone and made a lil' faux pas on your first day at the Ranch.
Well, welcome to JavaRanch, and please don't post the same question in multiple forums 'round these parts. It just makes it hard to follow a conversation. We'll let you off easy this time.
Good luck and I hope to see you 'round the Ranch!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!