File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes What is typeSafe enum ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "What is typeSafe enum ?" Watch "What is typeSafe enum ?" New topic
Author

What is typeSafe enum ?

Prabhat Ranjan
Ranch Hand

Joined: Oct 04, 2006
Posts: 391
Could any one elaborate Type Safe Enum with example ?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

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.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Siddhesh Deodhar
Ranch Hand

Joined: Mar 05, 2009
Posts: 117
Hi Prabhat,
Have a look at this article http://deepjava.wordpress.com/2006/11/21/type-safe-enumerations-in-java-50/ clearly explained enums.


Good, Better, Best, Don't take rest until, Good becomes Better, and Better becomes Best.
Sidd : (SCJP 6 [90%] )
Prabhat Ranjan
Ranch Hand

Joined: Oct 04, 2006
Posts: 391
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

Joined: Mar 05, 2008
Posts: 3012
    
  10
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.
 
Consider Paul's rocket mass heater.
 
subject: What is typeSafe enum ?