Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is typeSafe enum ?

 
Prabhat Ranjan
Ranch Hand
Posts: 397
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could any one elaborate Type Safe Enum with example ?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Type Safe Enum was a pattern you could use to get C style enums in Java before the enum construct was added to the language. These days they are only really of historical interest. See this for more.
 
Siddhesh Deodhar
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Prabhat,
Have a look at this article http://deepjava.wordpress.com/2006/11/21/type-safe-enumerations-in-java-50/ clearly explained enums.

 
Prabhat Ranjan
Ranch Hand
Posts: 397
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks it was good content enough to understand why it is typeSafe and difference from jdk1.4.

Good Topic.

Thanks Again!
 
Mike Simmons
Ranch Hand
Posts: 3090
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Sturrock wrote:Type Safe Enum was a pattern you could use to get C style enums in Java...

To be fair, typesafe enumerations were much more typesafe than C-style enums (which are still ints at heart, yes?). But they were also much more work to implement. The newer Java enums were significantly better than both, fortunately.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic