aspose file tools*
The moose likes Beginning Java and the fly likes What does Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "What does "type-safe" really mean?" Watch "What does "type-safe" really mean?" New topic
Author

What does "type-safe" really mean?

Pho Tek
Ranch Hand

Joined: Nov 05, 2000
Posts: 761

Context usage: "A type-safe enum pattern".
My understanding of the term "type-safe" is that
if a method expect type A, the compiler will throw
an exception is a term that is not assignable to A
is passed in? Any other characteristics?
Thanks
Pho


Regards,

Pho
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4419
    
    5

The compiler will also be able to catch an invalid assignment of the enumerated type to a variable of another type and vice versa.
These "pros" of typesafe enums are from "Effective Java" by Joshua Bloch:
- Constants may be added to a typesafe enum without recompiling its clients because the public static object reference fields containing the enumeration constants provide a layer of insulation between client and the enum class.
- Because they are full-fledged classes, you can override the toString method, internationalize them, or augment them with any method that seems appropriate.

------------------
Junilu Lacar
Sun Certified Programmer for the Java� 2 Platform


Junilu - [How to Ask Questions] [How to Answer Questions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What does "type-safe" really mean?
 
Similar Threads
Problem in generics
GC, local variables in methods
NX:what is type-safe?
Request Attributes Thread Safe?
List problem