Serialization is a process of saving the object state on a file in the local system. So that we can de-serialize( retrieve ) that object with data.rule to Serialize a java object.
To Serialize a java object, it must implements a Serializable interface.
Then create a FileOutputStream object of new file, and pass the references to ObjectOutputStream class and finally call the writeObject() method of ObjectOutputStream class to save the object to the file.
To de serialize the object create a FileInputStream reference variable passing the same file name in which, you have saved. Then create a ObjectInputStream class passing the FileInputStream reference and finally call the readObject() method of ObjectInputStream class to get the object.
You can mark a variable as transient whose state you don't wish to serialize.