Possible Duplicate:
what does the keyword “transient” means in java?
I read about transient keyword in java. What I understood is?. It was used for fields. If we declare transient keyword that field will not be serialized. When does the serializable was happens in java for an field?. How it happens without I am extending Serializable interface?. Please correct me If I say anything wrong. This question may be possible duplicate.
- Kannan
You would use it for fields you want to exclude from serialization. Serialization only applies to classes where either the class or a class in its class hierarchy implements the interface. For instance,
java.lang.Throwableimplementsjava.io.Serializable, so all Errors and Exceptions inherit that marker interface.