Serialization
The process of saving (or) writing state of an object to a file is called serializationbut strictly speaking it is the process of converting an object from java supported form to either
network supported form (or) file supported form.
By using FileOutputStream and ObjectOutputStream classes we can achieve serialization
process.
De-Serialization
The process of reading state of an object from a file is called DeSerializationbut strictly speaking it is the process of converting an object from file supported form (or)
network supported form to java supported form.
By using FileInputStream and ObjectInputStream classes we can achieve DeSerialization.
Serializable interface present in java.io package and does not contain any methods. It is
marker interface. The required ability will be provided automatically by JVM.
Transient keyword
While performing serialization if we don’t want to serialize the value of a particularvariable then we should declare that variable with “transient” keyword.
At the time of serialization JVM ignores the original value of transient variable and save
default value.
· That is transient means “not to serialize”.
Static Vs Transient:
· static variable is not part of object state hence they won’t participate in serialization
because of this declaring a static variable as transient these is no use.
Transient Vs Final:
· final variables will be participated into serialization directly by their values. Hence
declaring a final variable as transient there is no use.
0 comments:
Post a Comment